0 votes

Hello,

We use Mail.dll to convert .MSG to .EML with the following code :

using (MsgConverter converter = new MsgConverter(@"c:\outlook1.msg"))
{
    if (converter.Type == MsgType.Note)
    {
        IMail email = converter.CreateMessage();

        // Render message using MIME format to byte array
        byte[] mime = email.Render();

        // Save message to file using MIME message format
        email.Save(@"c:\mime.eml");
    }
}

This works well except for attachment with an accent in file name.

The attachment name seems to be encoding in iso-8859-1 and the converter use utf-8 so the name of the attachment is corrupted.

Example : if the attachment file name is étude.pdf in Outlook, in the .eml it's �tude.pdf the é (=E9) become =EF=BF=BD

Can you tell me how to fix that ?

Thanks!

by (200 points)
Can you please send zipped msg file, that causes this problem to the support email address in the page footer.

1 Answer

0 votes

Thanks for the file.

I run a simple unit test and don't see any problems:

[Test]
public void Test1()
{
    var email = new MsgConverter("c:\\TRVos.msg").CreateMessage();
    Assert.AreEqual(
        "Accusé de réception XXXXXXXXXXXXXXXX,.pdf",
        email.Attachments[0].SafeFileName);

    string fileName = "c:\\test1.eml";

    email.Save(fileName);
    email = new MailBuilder().CreateFromEmlFile(fileName);

    Assert.AreEqual(
        "Accusé de réception XXXXXXXXXXXXXXXX,.pdf",
        email.Attachments[0].SafeFileName);
}

File name is properly encoded in the file created on disk:

Content-Disposition: attachment;
 filename="=?utf-8?Q?Accus=C3=A9_de_r=C3=A9ception_XXXXXXXXXXXX=2C=2Epdf?="
by (301k points)
edited by
...