We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception when trying to update a contact


I have two problems the first one if I update a contact (for example a phone number) we lost the photos linked to him.
If I try to update a contact to add a photo, I get an exception.

IEWSClient client = EWSClient.GetEWSClient(“Url”, CredentialCache.DefaultNetworkCredentials);

MapiContact[] contacts = client .ListContacts(client.MailboxInfo.ContactsUri);

MapiContact c in contacts[0];

c.Telephones.MobileTelephoneNumber = “000000000000”;

client.UpdateContact©; // lost of images

/* Same beginning of code*/
c.Photo = new MapiContactPhoto(data, format); /* data is File.ReadAllBytes, format is the one corresponding to the selected photo generally MapiContactPhotoImageFormat.Jpeg/

client.UpdateContact©; // Exception

Object reference not set to an instance of an object.
at #=q0j6sve9S0kQRf$2i$i$OT3iYyGG8klnuRiMmnv0n5fn0kUyrUTbDDmd3Vurwhi$7GT0Qe5GbTNO3y6O8FIj61A==.#=qXQi2dTQyS09CE7ezpeMFzQ==()
at #=qfRXfyPuyzdEg71lIWeSugyuWFMRdWQnIEskGoKgkywRbBO7Pq1VUo9BtEJwcpk3o.#=qmIG70MlC_H5naJQ8frearw==()
at Aspose.Email.Mail.Contact.op_Implicit(MapiContact contact)


Best regards


Thank you for writing to Aspose Support team.

Please use the GetContacts method of IEWSClient to fetch and update contacts on the server. The ListContacts method is no more recommended and will soon be marked as deprecated. The following code sample will give you idea about working with Contacts on Exchange server.

Sample Code:

IEWSClient client = GetAsposeEWSClient1();
Contact[] contacts = client.GetContacts(client.MailboxInfo.ContactsUri, ExchangeListContactsOptions.FetchAttachmentAndFullPhotoInformation);
contacts[0].PhoneNumbers.Home = "12345679";
contacts[0].Photo = new ContactPhoto(File.ReadAllBytes("Jellyfish.jpg"), MapiContactPhotoImageFormat.Jpeg);