Creating Contact Information with Email

Do you have a sample that also set the Email address?

Here is my code:

MapiContact outlookContact = new MapiContact();
outlookContact.ElectronicAddresses = new MapiContactElectronicAddressPropertySet();
outlookContact.ElectronicAddresses.Email1 = new MapiContactElectronicAddress("", contact.Email);
outlookContact.NameInfo = new MapiContactNamePropertySet(contact.FirstName, contact.Initials, contact.LastName);
outlookContact.ProfessionalInfo.CompanyName = contact.CompanyName;
outlookContact.ProfessionalInfo.DepartmentName = contact.Department;
outlookContact.ProfessionalInfo.Title = contact.JobTitle;
outlookContact.Telephones = null;
contactType = client.CreateContact(outlookContact);

Each time I called the CreateContact I received this error:

The request failed schema validation: The element 'PhoneNumbers' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has incomplete content. List of possible elements expected: 'Entry' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.

Thanks Emmanue

This message was posted using Email2Forum by kashif.iqbal.

Hi Emmanuel,

Thank you for using Aspose.Email.

I was able to observe the issue as you have mentioned above. It seems that there are some validation rules binding in this case, which raises the exception if:

contact.Telephones = null;

If any of the Telephones numbers such as contact.Telephones.HomeTelephoneNumber is set to a value, the exception doesn’t occur and the contact is created using EWS.

Anyways, I have logged this issue in our issue tracking system for our development team to investigate it further. Once we have any information in this regard, we will update you here. The issue has been logged as: NETWORKNET-33489 in our issue tracking system.

As a work arround I added a bogus phone number:

outlookContact.Telephones = new MapiContactTelephonePropertySet();
outlookContact.Telephones.PrimaryTelephoneNumber = "n/a";
This is NOT a great solution so hopefully there is a fixe for it at some point
Thanks
Emmanuel
 

Hi Emmanuel,


We are sorry for the inconvenience you are facing.

I have already forwarded this issue to our development team for further investigation. We will update you here once we have any information in this regard. We are thankful to you for your patience towards the resolution of this issue.

Hi Emmanuel,


After analyzing this issue further, we found that this error occurs because server validation rules don’t allow to fill contact properties with empty values and user has to fill some values.

However, we have now provided the provision of default values in our library and this will allow you to create contact information now. Please download and use the latest version of Aspose.Email for .NET 2.4.0 for this purpose.