System.Net.Mail and =?utf-8?B?XXXXX… Headers

前端 未结 3 985
一生所求
一生所求 2020-12-03 06:58

I\'m trying to use the code below to send messages via System.Net.Mail and am sometimes getting subjects like \'=?utf-8?B?W3AxM25dIEZpbGV

3条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 07:38

    When your subject contains characters outside the ASCII range, then the mailing software must encode them (RFC2822 mail does not permit non-ASCII characters in headers). There are two ways to do this:

    • Quoted Printable (subject starts with "=?utf-8?Q")
    • Base64 (subject starts with "=?utf-8?B")

    It appears that the framework has figured that the Base64 encoding is more efficient (=shorter) than the quoted-printable encoding. This makes sense when your subject contains relatively many characters outside the ASCII range.

    To answer your question: You're doing nothing wrong. That's how internet mail with non-ASCII characters is supposed to look like. Of course, the software that reads such mail should detect and decode such subject fields.

提交回复
热议问题