Free Support Forum - aspose.com

Embedded Images in MapiMessage object

Greetings,

Do we have any collection in MapiMessage object similar to MailMessage.LinkedResources in order to access the embedded images?

Regards,
Syed.

Hello Syed,

I am sorry, there is no such public property. We will look into it further and update you with our findings.

No problem.

Rather, let me rephrase my question. My question should have been that how can I identify an attachment in a MapiMessage as an embedded attachment or a normal attachment. If an attachment is an embedded attachment then how can I identify if it is another embedded message (e.g. another EML file, or an MSG file), an image or a document, etc. And then how can I save both types of attachments (embedded and normal) to disk and/or access their various properties.

I hope I was able to make myself a bit clearer this time. And apologies for any inconvenience that my earlier post might have caused.

Regards,
Syed.

For embedded MSG attachments, please use the following code:

MapiMessage message = MapiMessage.FromFile(“Test.msg”);
foreach (MapiAttachment att in message.Attachments)
{
if (att.ObjectData != null &&
att.ObjectData.IsOutlookMessage == true)
{
Console.WriteLine("This is an embedded attachment. Name: " + att.LongFileName);
MapiMessage attMsg = MapiMessage.FromStream(new MemoryStream(att.ObjectData.Data));
}
else
{
Console.WriteLine("This is regular attachment. Name: " + att.LongFileName);
}
}

For handling embedded images, I will seek assistance from the developers and let you know.

For embedded images, you may use

MapiMessage msg = MapiMessage.FromFile(@“Test.msg”);
foreach (MapiAttachment att in msg.Attachments)
{
att.Save(att.LongFileName);
if (att.Properties.Contains(MapiPropertyTag.PR_ATTACH_CONTENT_ID_A) || att.Properties.Contains(MapiPropertyTag.PR_ATTACH_CONTENT_ID_W))
{
Console.WriteLine("Embedded Attachment File Name: " + att.LongFileName);
}
else
{
Console.WriteLine("Regular Attachment File Name: " + att.LongFileName);
}
}