cancel
Showing results for 
Search instead for 
Did you mean: 
Constant Contact wants to help you succeed! We’re celebrating our professional service programs on the Constant Contact Community this month and you have a chance to try one of the services for free! Learn more.

C#: Company Name not being added to contacts

Highlighted
Occasional Visitor

C#: Company Name not being added to contacts

Hello,

 

I am trying to develop an app that will import all of out current contacts from our CRM, and import them into a constant contact account.  I had no issues importing the contacts name and email address, but the company name refuses to get added. Im not exactly sure what needs to be done to add the complany name, the docs says that you simply need to pass a string in, but after testing on the website, it looks like a company acts as a list, letting you see who all belongs to that company. If anyone has any experiance with the C# wrapper, I would gladly appreciate the help. I will also put my code below. 

 

            foreach (var contact in contacts)
            {
                //Variable to store contact data
                var contactData = new AddContactsImportData();

                if (IsValidISO(contact.FirstName))
                    contactData.FirstName = contact.FirstName;
                else
                    Console.WriteLine(contact.FirstName + " has invalid characters");

                if(IsValidISO(contact.LastName))
                    contactData.LastName = contact.LastName;
                else
                    Console.WriteLine(contact.LastName + " has invalid characters");

                if(IsValidISO(contact.EMailAddress1) && IsValidEmail(contact.EMailAddress1))
                    contactData.EmailAddresses.Add(contact.EMailAddress1);
                else
                    Console.WriteLine(contact.EMailAddress1 + " is an invalid email address");

                contactData.CompanyName = "Sparkhound";

                importData.Add(contactData);
            }

            //list of tables to add contacts to
            var lists = new List<String>();
            lists.Add("1109363928");

            var columns = new List<String>();
            columns.Add("FIRST NAME");
            columns.Add("LAST NAME");
            columns.Add("EMAIL");
            columns.Add("COMPANYNAME");

            Console.WriteLine("About to add " + importData.Count() + " to account, press Enter to    coninue");
            Console.ReadLine();

            var addContact = new AddContacts(importData, lists, columns);
            Activity activity = null;

            try
            {
                activity = constantContact.CreateAddContactsActivity(addContact);
            }
            catch (CtctException e)
            {
                Console.WriteLine("{0} Exception caught.", e);
            }