The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

.Net Lib - Looking for samples - How to add a contact

Highlighted
Participant

.Net Lib - Looking for samples - How to add a contact

Do have any samples...


Looking for the syntax to add a contact to an existing list.


thx

3 REPLIES 3
Highlighted
Employee

Re: .Net Lib - Looking for samples - How to add a contact

In order for a contact to be added to your account, they need to be subscribed to at least one contact list. In the example below, the contact would be added list id 1, which is the 'General Interest' list by default.


Contact c = new Contact("joe@aol.com", "Joe", "Blow");



ContactOptInList cl = new ContactOptInList();

c.OptInSource = ContactOptSource.ActionByContact;

cl.ContactList = new ConstantContactBO.ContactList("1");

c.ContactLists.Add(cl);



Utility.CreateNewContact(authdata, c);

You can get a full listing of all the contact lists in your account by doing the following:


string nextChunkId;

IList<ContactList> lists = Utility.GetUserContactListCollection(authdata, out nextChunkId);

I hope this helps. Please let us know if you have any questions regarding this.

David J

Highlighted
Participant

Hi again.. This

Hi again..


This works


cl.ContactList = new ConstantContactBO.ContactList("1");

 


This does not


 


cl.ContactList = new ConstantContactBO.ContactList("CRM Data", true);

 


 

Highlighted
Employee

Re: Hi again.. This

If you are looking to add a contact to a list that already exists in your account called "CRM Data" you would want to reference the list using the id as shown above. Unfortunately we are not able to query our API by the name of the list at this time, so the list Id is the only way this can be done.


If however, you are looking to create a new list in your account, you would want to use code like the following:


Utility.addList("CRM Data", true, authdata);

We are looking to overhaul our C#.NET Library in the near future, and specifically around the functionality to do with creating Contact lists, and adding a contact to a specific list.

David J

Developer Portal

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

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured