Aspose.Email - Create, Save and Read Outlook Contacts

MapiContact contact = new MapiContact("Sebastian Wright", "SebastianWright@dayrep.com");
contact.setNameInfo(new MapiContactNamePropertySet("Bertha", "A.", "Buell"));
contact.setProfessionalInfo(new MapiContactProfessionalPropertySet("Awthentikz", "Social work assistant"));
contact.getPersonalInfo().setPersonalHomePage("B2BTies.com");
contact.getPhysicalAddresses().getWorkAddress().setAddress("Im Astenfeld 59 8580 EDELSCHROTT");
contact.getElectronicAddresses().setEmail1(new MapiContactElectronicAddress("Experwas", "SMTP", "BerthaABuell@armyspy.com"));
contact.setTelephones(new MapiContactTelephonePropertySet("06605045265"));

// Set Photo Data
File fi = new File(dataPath + "Aspose.jpg");
byte[] fileContent = Files.readAllBytes(fi.toPath());
MapiContactPhoto photo = new MapiContactPhoto(fileContent, MapiContactPhotoImageFormat.Jpeg);
contact.setPhoto(photo);

// Save as MSG
contact.save(dataPath + "contact.msg", ContactSaveFormat.Msg);

// Loading MSG
MapiMessage msg = MapiMessage.fromFile(dataPath + "contact.msg");

MapiContact mapiContact = (MapiContact)msg.toMapiMessageItem();


Download Source Code

For More Examples, Please Visit Aspose Docs

Last edited Jan 2, 2015 at 4:01 PM by shoaibkhan, version 1