I'm trying to find the total number of subscribers that are within a specific ExactTarget list. I have the ListID, and am successfully connecting to the list. Since the list has about 1 million subscribers, when I try to pull the subscribers with that ListID, it takes a really long time.
All I want is the number of subscribers. I don't need any information of theirs, just the amount that is apart of the list. Here's the simple code below:
//Make new request for number of subscribers in "All Subscribers" list
RetrieveRequest listSubscriberRequest = new RetrieveRequest();
listSubscriberRequest.ObjectType = "ListSubscriber";
listSubscriberRequest.Properties = new String[] { "SubscriberKey", "Status" };
// Setting up a simple filter to look at ListID
SimpleFilterPart sf = new SimpleFilterPart();
sf.SimpleOperator = SimpleOperators.equals;
sf.Property = "ListID";
sf.Value = new String[] { listId };
listSubscriberRequest.Filter = sf;
APIObject[] listSubscriberResults = null;
String listSubscriberRequestId = null;
String listSubscriberResponse = null;
int totalSubscribers = 0;
//Retrieve subscribers, add length of return to total every retrieve
do
{
listSubscriberResponse = soapClient.Retrieve(listSubscriberRequest, out listSubscriberRequestId, out listSubscriberResults);
totalSubscribers += listResults.Length;
}
while (listSubscriberResponse.Equals("MoreDataAvailable")); //Continue to loop until end of subscribers
I want to be able to get rid of that do while because it is taking 10+ min.