1
How to add a contact
Question asked by Michael Zuniga - March 11, 2016 at 3:50 PM
Unanswered
I am trying to copy the contacts from one Smarter Mail server to another. I have this code.
var contactList = sourceOutlookAddinServer.RequestContactListEx(Properties.Settings.Default.SmarterMailUser,                                      Properties.Settings.Default.SmarterMailPassword, userName);

if ( contactList.ResultCode == 0 )
{
    foreach (var contactInfo in contactList.List)
    {
        var contact = sourceOutlookAddinServer.GetContactEx(Properties.Settings.Default.SmarterMailUser, Properties.Settings.Default.SmarterMailPassword, userName, contactInfo.Guid);

        if (contact.ResultCode == 0)
        {
            ExContactItem newContact = new ExContactItem();
            newContact.key = new SmarterMailOutlookAddin.ArrayOfString();
            newContact.val = new SmarterMailOutlookAddin.ArrayOfString();

            for (int i = 0; i < contact.ExContact.key.Count; i++)
            {
                if (!string.IsNullOrWhiteSpace(contact.ExContact.val[i]))
                {
                    newContact.key.Add(contact.ExContact.key[i]);
                    newContact.val.Add(contact.ExContact.val[i]);
                }
            }
            var result = destinationOutlookAddinServer.AddContactEx(Properties.Settings.Default.SmarterMailUser, Properties.Settings.Default.SmarterMailPassword, userName, newContact);
        }

The result returns -2, Object reference not set to an instance of an object

The newContact is not null. It has values.

The destinationOutlookAddinServer is not null. It is valid.

The user is valid, and that user does exist on the destination server.

I even tried passing in the contact.ExContact into the AddContaqctEx call. Same result. Null reference exception.

What am I missing?

Reply to Thread