Aspose Email Contact Unit test


Pls find attached our AsposeContactTest class we built so as to test all individual attributes which are NOT populated correctly according to our tests.
Principle is simple and applied for each attribute:

  1. we create a MapiContact,
  2. insert 1 attribute,
  3. save MapiContact on Exchange test,
  4. retrieve contact using ListContacts procedure,
  5. compare attribute between MapiContact created and MapiContact retrieved

Pls tell us if anything wrong in our tests.
We would appreciate a complete answer on all attributes concerned.
Another problem is incoherence between Contact and MapiContact (could you please fix one of them and let us know which one we should use for all task)


Hi Stephan,

Thank you for writing to Aspose Support team.

For all practical purposes, we recommend the use of Contact class with EWSClient.GetContacts method. You can use it in your application for retrieving contacts and getting their properties. We are currently modifying your tests for working with Contact and will soon share our findings with you here.


We start with the contact class, but this class doesn’t works as well as MapiContact which only work as 60%.

We would like to enter all phone / address mail / other field for our internal information and photos but we were not able to do it with Contact class.

Could you please provide us the same test file as we gave you with contact class which pass them at 100%?

Best regards

Hi Stephan,

For adding photos, please use the Contact.Photo.Data property for setting image data. For fetching the information, you need to get it using:

client.GetContact(contactId, ExchangeListContactsOptions.FetchAttachmentAndFullPhotoInformation);

For the missing properties, following are our findings:

1. Following information could not be fetched using the Contact object from Exchange server and this issue has been logged as EMAILNET-38558 for further investigation by our Product team.
  • Account
  • Language
  • Physical Address Fields for Work, Home and Other addresses: Address, Country Code and IsMailingAddress, post office box
2. Following fields information could not be found in Contact class and have been forwarded to our Product team as EMAILNET-38559 for further feedback. Among these, the Gender property is not implemented and needs implementation.

  • FileUnder
  • Gender
  • Html
  • Location
  • OrganizationalIdNumber
  • UserField1
  • UserField2
  • UserField3
  • UserField4
  • Assistant
  • ManagerName
  • OfficeLocation
  • Email1
  • Email2
  • Email3
  • OtherTelephoneNumber
  • Business2TelephoneNumber

3. Conversion from MapiContact to Contact and back does not support extended properties yet. Extended properties support is new feature and it will take time for completion. Moreover, since properties such as UserFeiild1-4 are rarely used, we have plans to make them accessible via extended properties only instead of making them proper properties of Contact. You can mention if you need any further properties in this regard.

With respect to your requirement of Unit test requirement with Contact, we have identified the following properties as alternative to that of MapiContact. However, please note that these don’t include the ones mentioned in step 2 above.

  • MapiContactNameInfoSurname - Please use Contact.Surname
  • MapiContactNameInfoMiddleName - Please use Contact.MiddleName
  • MapiContactNameInfoDisplayName - Use Contact.DisplayName
  • MapiContactPersonalInfoAccount - Use Contact.Account (currently this property is not working)
  • MapiContactPersonalInfoLanguage - Use Contact.Language instead
  • MapiContactPersonalInfoNotes - Use Contact.Notes instead
  • MapiContactPersonalInfoSpouseName - Use Contact.AssocaitedPerson.Spouse
  • MapiContactEventsBirthday - Use Contact.Events.Birthday
  • MapiContactEventsWeddingAnniversary - Use Contact.Events.Anniversary
  • MapiContactProfessionalInfoCompanyName - Use Contact.Companyname
  • MapiContactProfessionalInfoDepartmentName - Use Contact.DepartmentName
  • MapiContactProfessionalInfoProfession - Use Contact.Profession
  • MapiContactProfessionalInfoTitle - Use Contact.JobTitle
  • MapiContactPhysicalAddressesWorkAddress - Use ContactAddress.WorkAddress
  • MapiContactPhysicalAddressesHomeAddress - Use Contact.PhysicalAddresses.HomeAddress
  • MapiContactPhysicalAddressesOtherAddress - Use Contact.PhysicalAddresses.OtherAddress
  • MapiContactTelephonesMobileTelephoneNumber - Use Contact.PhoneNumbers.Mobile
  • MapiContactTelephonesHomeTelephoneNumber - Use Contact.PhoneNumbers.Home
  • MapiContactTelephonesPagerTelephoneNumber - Use Contact.PhoneNumbers.Pager


is it funny to not be able to put emails in a contact which will be used to send e-mail?

Other thing:
Update doesn’t works on some fields (you can create them but not update hem)
And to update a contact with a photos you have to remove it and after re-add it. if you send the contact directly you have a null reference exception.

// ExchangeListContactsOptions added to get picture
MapiContact mapiContact = mailContact.ConvertToMapiContact(preloadedContact: client.GetContact(mailContact.InternalId, ExchangeListContactsOptions FetchAttachmentAndFullPhotoInformation));

// We keep a copy and remove Photo before conversion
MapiContactPhoto mapiPhoto = mapiContact.Photo;
mapiContact.Photo = null;

// Conversion
Aspose.Email.Mail.Contact contact = mapiContact;

// We push back Photo
if (null != mapiPhoto && mapiPhoto.Data.Length > 0)
    contact.Photo = new ContactPhoto(mapiPhoto.Data, mapiPhoto.PhotoImageFormat);


1. The missing fields, including the Email addresses, have already been mentioned to Product team for consideration and inclusion.

2. Update Contact has the same issue as reported in EMAILNET-38558 and we have further added the issue with this command to Product team.

3. The following code doesn’t raise exception when updating a contact for Photo. Please try it at your end and let us know your feedback.

Sample Code:

IEWSClient client = GetAsposeEWSClient1();

Contact[] contacts = client.GetContacts(client.MailboxInfo.ContactsUri, ExchangeListContactsOptions.FetchAttachmentAndFullPhotoInformation);

Contact contact = contacts[0];

//update the contact with new photo
contact.Photo = new ContactPhoto(File.ReadAllBytes(“File.jpg”), MapiContactPhotoImageFormat.Jpeg);



do you have a delivery date for EMAILNET-38558 ?



The issue is planned to be fixed in the upcoming version of Aspose.Email for .NET 17.1.0. We’ll update you here once there is some information or a fix version available in this regard.


for information we move this part using directly EWS Managed API.

Best regards


The issues logged under this thread have already been fixed and will be available in the upcoming release of Aspose.Email for .NET. We’ll update you here once the fix version is available for download and appreciate your patience until then,

The issues you have found earlier (filed as EMAILNET-38559;EMAILNET-38558) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.