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

Free Support Forum - aspose.com

Best practice

I have a message in Outlook which has two attachments; one is an Outlook Contact and the other is an Outlook Calendar Reminder item.

From Outlook I can Save the message to an msg file then I can open the msg file in an aspose MailMessage object, and I can see its Attachments collection has two members, as expected.

My question is - what is the best way to recreate the two attachments as aspose objects?

At the moment, when I enumerate the contents of the msg.Attachments collection I get two Attachment objects, but it's not clear to me how to turn one into a Contact and the other into a calendar Reminder.

My code currently gets the MIME content of each Attachment as a memory stream and uses that to construct a Word document. But the printed Word document looks like an email, not like a calendar reminder or contact.

I want to be able to print each attachment item so that its printout will be identical to what Outlook would produce if it were printing that item.

Hi Brian,

Thank you for contacting Aspose Support team.

Could you please share if using MapiMessage is an option at your end? This way you can use complete properties of a MSG file and use the following code sample to get information about the attachment type. Based on the Message class of attachment, you can save the attachment based on its type.

Sample Code:

MapiMessage mapi = MapiMessage.FromFile(“710496\Attachments reminder and contact.msg”);

foreach (MapiAttachment att in mapi.Attachments)
if (att.ObjectData.IsOutlookMessage)
MemoryStream ms = new MemoryStream();
ms.Position = 0;
MapiMessage attMsg = MapiMessage.FromStream(ms);


Thank you for the rapid reply Kashif. I’ll try the supplied code sample out and let you know how I get on.

Hi Brian,

Sure. Please feel free to write to us if the suggested code doesn’t meet your requirements. We’ll look into these for assisting you further.