I am having trouble reading the attachments from an Outlook email message (.msg). I create a MapiMessageReader from a stream and reading the attachments, the first 3 are correct, but all the rest of the attachments are only 146 bytes big and incorrect. Is there something I’m doing wrong? Is there a property I can set to change this?
If you are trying to extract attachments from a MSG file without applying a license, only the first 3 attachments shall be extracted and the rest won’t be extracted properly. This is an evaluation limitation. However, you can get a 30-day temporary license and test all the features of the API without any evaluation limitations. In order to request your temporary license, please visit the licensing page.
Once you get a temporary license, you can use the following code to extract attachments from the MSG file.
MapiMessage mapi = MapiMessage.FromFile("Attachments.msg");
foreach (MapiAttachment att in mapi.Attachments)
{
att.Save(att.LongFileName);
}
Sure. Just make sure that license initialization should be done before referencing the Aspose.Email API. Please feel free to contact us if you have any additional query/inquiry. We’ll be glad to assist you further.