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

Free Support Forum - aspose.com

Create Contact with Photo

Hi again,

We need to create a contact on Exchange Server but wnat to have its image also in it. Is there any code sample you can share?

Hi Aaron,


You can use the following sample code to create an Exchange Contact with Photo information in it. Please try it at your end and share your feedback with us.

Code:

<span style=“font-size:
9.5pt;font-family:Consolas;mso-fareast-font-family:“Times New Roman”;
mso-bidi-font-family:Consolas;color:#2B91AF;background:white;mso-highlight:
white”>MapiContact contact = <span style=“font-size:9.5pt;font-family:Consolas;mso-fareast-font-family:“Times New Roman”;
mso-bidi-font-family:Consolas;color:blue;background:white;mso-highlight:white”>new
<span style=“font-size:9.5pt;font-family:Consolas;mso-fareast-font-family:
“Times New Roman”;mso-bidi-font-family:Consolas;color:#2B91AF;background:white;
mso-highlight:white”>MapiContact();<o:p></o:p>

contact.NameInfo = new MapiContactNamePropertySet("Bertha", "A.", "Buell");

contact.ProfessionalInfo = new MapiContactProfessionalPropertySet("Awthentikz", "Social work assistant");

contact.PersonalInfo.PersonalHomePage = "B2BTies.com";

contact.PhysicalAddresses.WorkAddress.Address = "Im Astenfeld 59 8580 EDELSCHROTT";

contact.ElectronicAddresses.Email1 = new MapiContactElectronicAddress("Experwas", "SMTP", "BerthaABuell@armyspy.com");

contact.Telephones = new MapiContactTelephonePropertySet("06605045265");

//Add a photo

using (FileStream fs = File.OpenRead("Desert.jpg"))

{

byte[] buffer = new byte[fs.Length];

fs.Read(buffer, 0, buffer.Length);

contact.Photo = new MapiContactPhoto(buffer,

MapiContactPhotoImageFormat.Jpeg);

}

IEWSClient client = GetAsposeEWSClient();

client.CreateContact(contact);