Incorrect Attachment Name for non ASCII character

Hi, When processing emails that have attachment names that are not in standard ASCII, they do not have the correct encoding applied.

In my attached sample code, There is the same characters in the subject as the attachment name.

Things to note. I do supply preferred encoding of UTF-8, and the subject part gets applied, but the attachment name does not. (I think this may be where the issue is).
Chinese Character in Attachment (5.7 KB)

Thanks Charles


If you save the .eml file to .txt file format using MS Outlook, you will get the same output.

Could you please share your expected output here for our reference? We will then provide you more information on it.

My expected output would be to match the Chinese character as it is displayed in the subject.
In the eml file the subject has ‚¡5S¡.xls, which is the same text in the attachment name. The subject converts the character to the Chinese character correct, yet the attachment name does not. The subject seems to return the encoding UTF-8, but the attachment returns blank for the encoding, even though I specify UTF-8 encoding for the preferred encoding when loading the eml file.
image.png (9.6 KB)



We have logged this problem in our issue tracking system as EMAILNET-40578. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


The subject is displayed correctly because the subject header contains the name of the encoding. The attachment does not specify the encoding in which its name was encoded. So one way to get the correct attachment name is to set the correct encoding as shown below:

MailMessage msg = MailMessage.Load(fileName, new EmlLoadOptions() { PrefferedTextEncoding = Encoding.GetEncoding(936) });