EML Corruption issue: Content-Disposition header mangled

Today we came across a showstopping bug in Aspose.Network. We are using version 4.8.0.12.

E-mails with attachments are get corrupted. The easiest way to reproduce is simply opening them and saving them back to disk.

Specifically, a double newline (\r\n\r\n) gets added in the middle of attachments’ Content-Disposition header value. This causes mail clients to parse the rest of the Content-Disposition header as the beginning of the attachment so the attachment appears corrupt and cannot be opened.

Type for example, original header snippet (mail client was Outlook XP):

004_9DCABDD8D9EEF0459CF2B21A21CBDA351FA0D49954WINDOWSSWXF47
Content-Type: application/msword; name="Bookmarks.doc"
Content-Description: Bookmarks.doc
Content-Disposition: attachment; filename=“Bookmarks.doc”; size=31744;
creation-date=“Tue, 09 Feb 2010 15:24:45 GMT”;
modification-date="Thu, 11 Feb 2010 18:41:52 GMT"
Content-Transfer-Encoding: base64

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgAD…

Header snippet after Save(file, MessageFormat.Eml) call:

----_=_NextPart5_f7f53389-2fc2-41ff-a669-9ea31ab018fa
Content-Type: application/msword; name=Bookmarks.doc
Content-Transfer-Encoding: base64
Content-Description: Bookmarks.doc
Content-Disposition: attachment; filename=“Bookmarks.doc”; size=31744;

creation-date=“Tue, 09 Feb 2010 15:24:45 GMT”;
modification-date="Thu, 11
Feb 2010 18:41:52 GMT"

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgAD…

Notice the extra \r\n starting at creation-date. This is invalid mime and causes a rather large problem for us.

Reproducing the bug should not be hard. Here is sample code. I have also attached a sample EML file.

internal class Program
{
private static void Main(string[] args)
{
string filename = args[0];
MailMessage msg = MailMessage.Load(filename);
string newfile = Path.ChangeExtension(filename, “.aspose.eml”);
msg.Save(newfile, MailMessageSaveType.EmlFormat);
}
}

Hello again,

Please note that this is also a problem with inline attachments. I have attached another e-mail file with an inline image that exhibits this behavior.

In a way this is even worse problem than previous one, because we cannot set the content disposition on a LinkedResource as a workaround (no ContentDisposition property exposed).

Overall I’m finding it hard to find anything involving content disposition header that works properly. More examples:

I noticed when I add a new LinkedResource, no “Content-Disposition: inline” header is written out during Save(). This is technically wrong, and many e-mail clients will not display the e-mail properly, including Outlook.

The properties of Attachment.ContentDisposition don’t appear to be set correctly, aside from the Inline boolean. Also, setting any of these properties does nothing aside from Inline.

Thanks,
Scott

Hi Scott,

I can reproduce this bug using the test eml file. I have added this issue in our bug tracking system (ID: 14342). We will notify you as soon as we make any progress to fix this. Sorry for the inconvenience.

The issues you have found earlier (filed as 14342) have been fixed in [this update ](http://www.aspose.com/community/files/51/.net-components/aspose.network-for-.net/entry224476.aspx).

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