Getting embedded attachments from richtext-msg file

Hello,

we are using Aspose.Email.NET for extracting attachments from a msg file. When the msg file is saved in outlook-rtf-format and the attachments are embedded into the text, Aspose seems not to be able to access these attachments.

I’ve tried the following code to load the message file:

mMessage = Aspose.Email.MailMessage.Load(@“c:\test\test.msg”, new Aspose.Email.MsgLoadOptions());
MessageBox.Show(mMessage.Attachments.Count.ToString());

The attachment-count is always 0.

Do i have to set some special options to get access to the attachments or is this simple not possible?

Thank you for any help.

Regards,

@Eco,

We have tested this with the latest version of the API and were not able to reproduce the problem with sample files at our end. Please share your sample msg files with us for further investigation at our end. Also, please try it with the latest version of Aspose.Email for .NET 17.9 at your end if you are not already doing so.

testrtf.zip (151.5 KB)
Thank you for your answer. I’m already using the latest version 17.9.

I’ve uloaded a sample msg file which shows the behaviour. Full example code:

Aspose.Email.MailMessage mMessage = null;
Aspose.Email.MsgLoadOptions msgLoadOptions = null;

try
{
msgLoadOptions = new Aspose.Email.MsgLoadOptions();

mMessage = Aspose.Email.MailMessage.Load(@"c:\temp\testrtf.msg", msgLoadOptions);

MessageBox.Show(mMessage.Attachments.Count.ToString());

}
finally
{
if (mMessage != null)
mMessage.Dispose();
}

@Eco,

Please use mMessage.LinkedResources.Count to get the information about embedded images inside message body.

foreach (LinkedResource lr in eml.LinkedResources)
    Console.WriteLine(lr.ContentType.Name);

Works, thanks for your help!

@Eco,

You are welcome.