none
UTF-8 subject encoding does not work for all recipients RRS feed

  • Question

  • (I originally asked this question here
    https://social.technet.microsoft.com/Forums/msonline/en-US/d1287b5d-2f43-41b6-a091-7ec80526c4fe/utf8-subject-encoding-does-not-work-for-all-recipients?forum=onlineservicesexchange#d1287b5d-2f43-41b6-a091-7ec80526c4fe
    but was redirected here)

    We have developped a custom newsletter mailing application that worked several years with a local exchange server without any problems.

    Now we changed to Office 365 and try to use the same program with the SMTP server of Office 365.

    Our e-mail messages and subjects may contain non-ascii characters (German Umlaute) which never was a problem. In our code we use Microsofts System.Net.Mail.SmtpClient with the following settings:

    MailMessage mm = new MailMessage();
    mm.From = new MailAddress(Sender);
    mm.ReplyToList.Add(new MailAddress(Sender));
    mm.IsBodyHtml = true;
    mm.BodyEncoding = Encoding.UTF8;
    mm.Headers["Content-Language"] = "de-DE";
    mm.Subject = "Rabatt und Rückvergütung";
    mm.SubjectEncoding = Encoding.UTF8;

    We send this e-mail to clients of different providers and in most clients everything works as expected. Some clients, however, don't display the non-ascii characters in the subject correctly. At the same time non-ascii characters in the text body are displayed correctly.

    This is part of the raw e-mail display in one of the problematic clients:

    Content-Language: de-DE
    MIME-Version: 1.0
    From: "Hans Muster" <hans.muster@muster.de>
    To: frida.muster@muster.de 
    Reply-To: "Hans Muster" <hans.muster@muster.de>
    Date: 16 Oct 2017 16:01:56 +0200
    Subject: Rabatt und R��ckverg��tung
    Content-Type: text/html; charset=utf-8
    Content-Transfer-Encoding: base64

    Then I sent the same e-mail via another e-mail server (not via Office 365) which does not show the problem and results in this (in the same e-mail client!)

    Content-Language: de-DE
    MIME-Version: 1.0
    From: "Hans Muster" <hans.muster@muster.de>
    To: frida.muster@muster.de 
    Reply-To: "Hans Muster" <hans.muster@muster.de>
    Date: 16 Oct 2017 14:39:50 +0200
    Subject: =?utf-8?B?UmFiYXR0IHVuZCBSw7xja3ZlcmfDvHR1bmcgZGlkYWN0YSAy?= =?utf-8?B?MDE4IEhhbm5vdmVy?=
    Content-Type: text/html; charset=utf-8
    Content-Transfer-Encoding: base64

    The subject clearly got base64 encoded and in the normal e-mail display is shown correctly with all non-ascii characters.

    In another test we sent the same e-mail via Office 365 but not with our custom program but with Outlook which does also not show the problem and results in this:

    Subject: =?utf-8?B?QVc6IFLDvGNrdmVyZ8O8dHVuZyBkaWRhY3RhICYgdmllbGUg4oKsIGFuIGRp?= =?utf-8?B?ZSBzY2jDtm5lbiBWZXJsYWdlIC0gbXXDnyBkYXMgc2Vpbj8g?=
    Content-Language: de-DE Content-Type: multipart/alternative; boundary="_000_AM5PR10MB15569068F28499685B1D1A48AB4F0AM5PR10MB1556EURP_"

    The subject was slightly different here but you can see that it also got base64 encoded and has some utf-8 prefix.

    What are we doing wrong? Why does the display of non-ascii characters fail for some clients when we use Office 365 SMTP?

    Thanks in advance,

    Nicolas 

    Tuesday, October 17, 2017 10:05 AM