简体   繁体   中英

MailMessage.Subject Finnish encoding

I'm trying to send a Finnish email with "Käyttörajan muutos" in subject.

Tried different encodings:

message.Subject = "=?iso-8859-1?B?" + Convert.ToBase64String(Encoding.GetEncoding(1252).GetBytes(strSubject)) + "?=";

and

message.Subject = "=?utf-8?B?" + Convert.ToBase64String(Encoding.UTF8.GetBytes(strSubject)) + "?=";

As a result I get:

Käyttörajan muutos

Does anyone have a solution for this problem?

The main problem was, when I was implementing subject from Request, I was using

HttpUtility.HtmlEncode(Request.Form["strSubject"]);

And this already encoded my string to "Käyttörajan muutos" .

So,

message.Subject = "=?utf-8?B?" + Convert.ToBase64String(Encoding.UTF8.GetBytes(strSubject)) + "?=";

works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM