We all started somewhere! Share your experience on the Get Advice: Let's Get Started Sweepstakes thread and be entered to win a $100 credit on your Constant Contact account.

Checking if a Contact in a Contact List in C#

Regular Participant

Checking if a Contact in a Contact List in C#

How to I check to see if a contact is in a contact list?  I'm looking at contact.Lists.Exists where contact is my Contact, but having trouble in figuring out to use the right syntax.  I've tried:


if (contact.Lists.Exists) 


  // Do Something



but know this is not correct.  What is the correct syntax?  Thanks.

Regular Participant

Another way I'm looking at is by getting the contacts from a list using getcontactsfromlist.  Can I use Results.Contains to check if a users email address is in the list?  If so, what is the correct syntax?  What I have so far is:



<Contact> contacts = cc.GetContactsFromList("22", DateTime.Now.AddMonths(-1));


I know it will then begin with contacts.Results.Contains.  What do I put for the item?


If you're looking for a specific contacts information, it's likely easier to just search for that email address using our search feature.  You can find more information on that on this page in the documentation: http://developer.constantcontact.com/docs/contacts-api/contacts-collection.html


In the .Net wrapper, you would use the GetContacts() method and provide an optional email address to search for.  This will let you know if the Contact exists and get you information on said Contact.

Dave Berard
Senior Product Manager, Constant Contact



Thanks for posting.  The Contains method requires an argument of the same type that the List is.  So you would have to create a new Contact object to perform the search.  I would advise against this way of searching.  The Contains method will search for a complete, perfect match of objects, not just one field.  A good way to search would be to iterate through the list and compare each object's email address(es) against what you are looking for.  Hope that helps.




Andrew B.

Constant Contact

API Support

Developer Portal

View API documentation, code samples, get your API key.

Visit Page