MailSystem.NET subject encoding

梦想与她 提交于 2019-12-05 00:47:35

问题


I'm currently using MailSystem.NET SMTPClient to send email, the email content contains Chinese character in both Subject and Body. By the following code, I'm able to set the Email's body to be Encoded correctly, but Subject is still not Encoded and appeared as ???? in Received Email.

 ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message();
 ....
 message.Charset = "utf-8";
 SmtpClient.Send(message, serverName);

Could anyone familiar with MailSystem.Net kindly tell me how to set the subject as encoded in utf-8 as well? Thanks.


回答1:


I had a similar problem with Polish chars in my email subjects. Solved it this way (VB.NET):

message.Subject = "=?UTF-8?B?" &
    Convert.ToBase64String(Encoding.UTF8.GetBytes(outboxMessage.Title)) &
    "?="

Now everything works as expected.



来源:https://stackoverflow.com/questions/17696519/mailsystem-net-subject-encoding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!