Incorrect conversion of EML with attachment

I’m trying to convert an EML with an attached pdf document to a pdf. But the attached document is not converted correctly.
We get PDF with incorrect attachment file name : “ATT00001.bin” but the name must be “ÅåÄäÖöÆæØøÅåÀÉÜàéü.pdf”
When loading MailMessage, we already get an invalid attached file.

MailMessage message = MailMessage.Load(inputFilePath);

I try to convert this EML by using ASPOSE but get same incorrect result.

Input file :
Input-file.zip (964.1 KB)

Result file:
result.pdf (42.0 KB)

Hello @uaprogrammer,

Any header values ​​in eml files must not contain non-ASCII characters. The MIME standard requires that all values in headers must be in ASCII, which also applies to the attachment filename.

If you need to use non-ASCII characters for the filename, it is recommended to use MIME encoding (e.g., base64 or Quoted-Printable).

Thus, the filename ÆæØøÅåÀÉÜàéü.pdf should be encoded as =?utf-8?B?w4bDpsOYw7jDhcOlw4DDicOcw6DDqcO8LnBkZg==?=.

To fix the issue, open the original .eml file in any text editor, and replace line 19:
Content-Type: application/octet-stream; charset=UTF-8; name=ÆæØøÅåÀÉÜàéü.pdf
with
Content-Type: application/octet-stream; charset=UTF-8; name="=?utf-8?B?w4bDpsOYw7jDhcOlw4DDicOcw6DDqcO8LnBkZg==?=", save the file.
After this, the attachment name will be processed correctly.

1 Like

Thank you for help

@uaprogrammer ,

Thank you for your feedback.

If you have further questions or need assistance, feel free to ask.