심재운 블로그

 

1. 검토할 사이트

 

 

 

Like MapiMessage, Aspose.Email allows you to create Outlook contacts. The [{{MapiContact}}] class provides all the contact related properties required to create an Outlook contact. This article shows how to create, save and read an Outlook contact using the MapiContact class.

Working with Outlook Contacts

Create and Save Outlook Contact

To create a contact and save it to disc:

  1. Instantiate a new object of the MapiContact class.
  2. Enter contact property information.
  3. Add photo data (if any).
  4. Save the contact as MSG or VCard format.
MapiContact contact = new MapiContact();
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");
contact.PersonalInfo.Children = new string[] { "child1", "child2", "child3" };
contact.Categories = new string[] { "category1", "category2", "category3" };
contact.Mileage = "Some test mileage";
contact.Billing = "Test billing information";
contact.OtherFields.Journal = true;
contact.OtherFields.Private = true;
contact.OtherFields.ReminderTime = new DateTime(2014, 1, 1, 0, 0, 55);
contact.OtherFields.ReminderTopic = "Test topic";
contact.OtherFields.UserField1 = "ContactUserField1";
contact.OtherFields.UserField2 = "ContactUserField2";
contact.OtherFields.UserField3 = "ContactUserField3";
contact.OtherFields.UserField4 = "ContactUserField4";

//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);
}
//Save the Contact in MSG format
contact.Save("MapiContact.msg", ContactSaveFormat.Msg);

//Save the Contact in VCF format
contact.Save("MapiContact.vcf", ContactSaveFormat.VCard;

Reading a MapiContact

The MapiContact class can be used to load both Outlook MSG and VCard format contacts. The following code samples show how to load Outlook contacts saved as MSG and VCF into a MapiContact.

Loading a Contact from MSG
MapiMessage msg = MapiMessage.FromFile("MapiContact.msg");

MapiContact mapiContact = (MapiContact)msg.ToMapiMessageItem();
Loading a Contact from VCard
var vcfTest = VCardContact.Load("C://Jon.vcf");

MapiContact contact = MapiContact.FromVCard("C://Jon.vcf");

이 글을 공유합시다

facebook twitter kakaoTalk kakaostory naver band

본문과 관련 있는 내용으로 댓글을 남겨주시면 감사하겠습니다.

비밀글모드