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

Free Support Forum - aspose.com

Losing attachments when using MailMessage.Load

Hello,

I am loading a mail message (in msg format) using MailMessage.Load as a Stream, i.e.

MailMessage message = MailMessage.Load(stream, MessageFormat.Msg);

When the mail message was converted to the stream it had an attachment (PDF document). However, after the Load() method the reconstructed message does not have any attachments.

I have attached a copy of the email that is causing this problem.

I am using .NET v4.0 and Aspose v5.4.

I would appreciate if this could be investigated.

regards

Ronnie

Hi Ronnie,


Thanks for you inquiry.

I have tested this file with v5.7 at my end with MailMessage class. The PDF file is not coming in the MailMessage.Attachments collection. However, I could see it in the LinkedResources collection and was able to save using the below example code:

MailMessage msg = MailMessage.Load(@“FW Conservative Party Conference Information.msg”, MessageFormat.Msg);
foreach (LinkedResource resource in msg.LinkedResources)
{
Console.WriteLine("Resource: " + resource.ContentId + " - " + resource.ContentType.MediaType);
switch (resource.ContentType.MediaType)
{
case “application/pdf”:
resource.Save(resource.ContentId + “.pdf”);
Console.WriteLine(“Saved pdf”);
continue;
default:
resource.Save(resource.ContentId);
continue;
}
}

I will get back to you with some more information why it is not coming in the Attachments collection. Sorry for the inconvenience.

Hi Saqib,

Thank you for your response.

The problem with the work around is that linked resources do not have the file name. I require the original file name of the attachment to persist it to a data store.

Have you discovered the reason why the attachment is not in the Attachments collection?

kind regards

Ronnie

Hello Ronnie,


We are looking into the reason why it is missing from the Attachments collection and also a way to get the file name from the linked resource. I have also logged an issue for this in our system (ID: 20786) and will get back to you when these issues will be resolved. Sorry for the inconvenience.

Hello Saqib,

Re: ID 20786

Thank you for the update.

1. Have the developers informed you about the ETA?

2. Do you have any information why that particular email lost its attachments?

I have a customer who requires a fix for this issue; therefore, any information would be appreciated.

Hi Ronnie,


This issue has been included in this week’s schedule. Hopefully, I will have some updated information or solution by the end of this week.