Referring to the MIME Encoded-word syntax on wikipedia:
=?charset?encoding?encoded text?=
I want to specify both charset and encoding for my MailAddress.DisplayName
, MailMessage.Subject
etc.
For examples:
- charset ISO-2022-JP with Q encoding:
=?iso-2022-jp?Q?=5B=1B=24B=21A=1B=28B=5D=5B=1B=24B=21B=1B=28B=5D?=
- charset ISO-2022-JP with Base64 encoding:
=?ISO-2022-JP?B?WxskQiFBGyhCXVs=?=
It seems like current .NET framework implementation does not allow this flexibility. The encoding-related properties (such as MailMessage.SubjectEncoding
) maps to MIME charset, and there is no way to specify MIME encoding. The MIME encoding is set by the framework like the following:
If the MailMessage.SubjectEncoding is set to UTF-8 (the default), UTF-32, Unicode or BigEndianUnicode AND the subject contains non-ASCII characters, then it will be encoded in Base64. Otherwise it will be encoded in Quoted Printable. (Source: Microsoft Connect)
If using MailMessage class is not possible, is there any other way to achieve this?