Retrieving Contacts & Calendars from .msg Files

We have been using the MapiContact and Appointment classes with VCards and iCalendars, respectively, but now we’d like to use .msg files. Is there a way to create these classes with .msg files, or are there equivalent classes to represent contacts and calendars?


In other words: in Outlook, I can save contacts and calendar appointments as .msg files. Can I retrieve their data with an Aspose tool?

Hi Dev,


Thank you for writing to Aspose Support team.

The MapiMessage class is the general class for loading all objects of .MSG type. You can use this class to load any such objects and then cast these to respective type for further processing. In below code sample, we have shown how to process a Contact and a Calendar item. Please try these at your end and share your feedback with us if you need further information.

Code:


MapiMessage contactMsg = MapiMessage.FromFile(“New Customer On Net.msg”);


MapiContact contact = (MapiContact)contactMsg.ToMapiMessageItem();


Console.WriteLine(contact.ElectronicAddresses.Email1.EmailAddress);


MapiMessage calendarMsg = MapiMessage.FromFile(“App With Attachments.msg”);


MapiCalendar calendar = (MapiCalendar)calendarMsg.ToMapiMessageItem();


Console.WriteLine(calendar.StartDate);


Console.WriteLine(calendar.Subject);

Thanks a lot, that’s what I was looking for!

Hi,


You are welcome and please feel free to write to us if you have any further query about the API.