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

Free Support Forum - aspose.com

Eml file attachments getting corrupt

Hi,
We are using Aspose Network 5.0 and have an Aspose.Total license purchased. We find that if an eml file has an embedded eml file then when calling MailMessage.Save the resulting file on disk is corrupt for all other eml readers I can find: thunderbird, outlook express etc.

The uploaded attachment contains the source eml file and the result eml that is generated with only a Load and Save call. Sample code is for example:

var originalMs = new MemoryStream(Resources.art4901_orig);
var res = Aspose.Network.Mail.MailMessage.Load(originalMs);
Assert.AreEqual(2, res.Attachments.Count());
MemoryStream ms = new MemoryStream();
res.Save(ms);
res.Save(@“c:\result.eml”, MailMessageSaveType.EmlFormat);
Assert.AreEqual(originalMs.Length, ms.Length);


Firstly the lengths of the two memory streams are not the same and more importantly opening up the result.eml shows that the attachments have essentially dissappeared and substituted with bogus entries.

This is a very serious issue and we would appreciate your speedy confirmation of this bug and possibility of a fix or a workaround for now.

best regards,
Laku.
artf4901

PS: running platform is .NET 3.5 64bit Windows 2008

Hi Laku,

I tried to open the result.eml file in the following programs and I was able to open the file and view the nested eml attachments. Each eml further contained a docx file, which was also opening successfully.

  1. Windows Live Mail on Windows 7 x64
  2. Outlook Express on Windows XP x86
I also tested loading the original eml file and saving the file with another name on disk. It was also opening the saved file correctly with both the above programs.

The only issue is the file names of the attachments, they are coming as ATT00001.eml and ATT00002.eml. I have logged a bug for this issue (ID: 15949).

Hi Saqib,
Thanks for your response and you have possibly discovered that the bug manifests itself differently for different clients. The failures to open are on, for example:

1) hotmail.com
2) gmail.com
3) Thunderbird 3.0.4
4) Microsoft Outlook 2007
5) Aspose.Network 5.0

Importantly and interestingly neither Aspose.Network itself is able to parse the resulting email. I have attached a simple complete program that illustrates the following sequence:
1) Load message in Aspose
2) Recurse through attachments printing out the contents of any nested messages found i.e. for content type == message/rfc822
3) Save message to a new file
4) Reopen new file in Aspose
5) Recurse again through attachments

Step 5 for me does not work and Aspose does not seem to recognize the messages in this context. I did some further investigation and believe the issue is related to the fact that Aspose is converting the nested eml to base64 encoding, which is not necessary as the attachment is already a well formed rfc822 message anyways. I think that is what is confusing some readers as well as the Aspose library itself. I verified this by manually decoding the base64 and pasting it back into the EML.


The subject issue is something I believe we can workaround to facilitate our pending release but I cant see any way past the base64 issue.

Thanks for your help so far. From this code I conclude that its not just a renaming issue.

best regards,
L.




After compiling the program you can run it from the debug location with the command line:

AsposeMailTest.exe art4901.orig.eml

This is the result I get:


Loading original file: art4901.orig.eml
Printing out structure of mail message, recursing through nested EML files
Attachment name ATT00001.eml is of type: message/rfc822
Attachment name TrackChanges.docx is of type: application/octet-stream
Attachment name ATT00002.eml is of type: message/rfc822
Attachment name TrackChanges.docx is of type: application/octet-stream

Now saving mail message with MailMessage.Save(C:\Users\lakua\AppData\Local\Temp<br>1\tmpDE66.tmp)…
Reloading mail message from new location C:\Users\lakua\AppData\Local\Temp\1\tmp
DE66.tmp
Printing out structure of mail message, recursing through nested EML files
Attachment name ATT00001.eml is of type: message/rfc822
Attachment name ATT00002.eml is of type: message/rfc822





Hi Laku,

Thanks for clarifying the issue. I have produced it at my end with v5.1. On re-load of the eml file, the attachments in nested eml files could not be loaded.

I have logged this bug in our issue tracking system (ID: 15969). We will notify you as soon as we make some progress on it. Sorry for the inconvenience.

The issues you have found earlier (filed as 15969;15949) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.