Mail with polski characters

0 votes
asked Dec 13, 2021 by toty (140 points)

Hi, i have stored one mail with poski characters. MS outlook display the message correctly, but your class Rebex.Mail.MailMessage display wrong subject and wrong sender name.

Subject from Rebex.Mail.MailMessage:
WĂłzki widĹ'owe
The correct subject:
Wózki widłowe

eml:
Received: from HE1EUR01FT006.eop-EUR01.prod.protection.outlook.com
To: potwierdzeniesalda@fortum.com
Content-Transfer-Encoding: 8bit
From: "Wózki widłowe" biuro@wozkiwidlaki.pl
Content-type: text/plain; charset=utf-8
Subject: Wózki widłowe
Date: Mon, 06 Dec 2021 11:15:07 +0100

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Dec 13, 2021 by Lukas Pokorny (128,250 points)
edited 6 days ago by Lukas Pokorny

Hi,

please note that the From and Subject headers in the EML file are wrong - they contain non-ASCII characters, but are not using proper header encoding as specified by the MIME standard.

This generally means that applications parsing these messages are free to handle them as they wish. It looks like MS Outlook is lucky enough to use UTF-8 in this case, but Rebex Mail's default is the charset configured as default in the OS, which seems to be "windows-1250" (Central and Eastern Europe) in your case, and that unfortunately does not match the header charset.

Therefore, the proper solution to the issue described is to fix the application that created the mail message (as represented by the EML file). The correct MIME-compliant form of the Subject header is supposed to look like these, for example:

Subject: =?utf-8?Q?W=C3=B3zki_wid=C5=82owe_?=
Subject: =?windows-1250?Q?W=F3zki_wid=B3owe_?=

Rebex Mail R6.1 or later has an option that makes it use UTF-8 for non-ASCII headers as well:

var message = new MailMessage();
message.DefaultCharset = System.Text.Encoding.UTF8;
message.Settings.UseDefaultCharsetForHeaders = true;
message.Load("message.eml");

In earlier versions, use this instead:

var message = new MailMessage();
message.DefaultCharset = System.Text.Encoding.UTF8;
message.Options |= (MimeOptions)0x400000; // force default charset for non-ASCII headers
message.Load("message.eml");

Please let us know whether this successfully works around the issue.


Another issue in the EML message is lack of angle brackets around the e-mail address in the From header, which are mandatory.

...