MailSystem.NET主题编码 [英] MailSystem.NET subject encoding
问题描述
我目前正在使用MailSystem.NET SMTPClient发送电子邮件,电子邮件内容包含主题和正文中的汉字。通过以下代码,我可以将电子邮件的正文设置为正确编码,但是Subject仍然没有编码并显示为????在收到的电子邮件中。
ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message();
....
message.Charset =utf-8;
SmtpClient.Send(message,serverName);任何熟悉MailSystem.Net的人都可以告诉我如何将主题设置为utf-8中的编码方式还有吗谢谢。解决方案我的电子邮件主题中有与波兰语字符类似的问题。以这种方式解决(VB.NET):
message.Subject ==?UTF-8?B? &安培;
Convert.ToBase64String(Encoding.UTF8.GetBytes(outboxMessage.Title))&
?=
现在一切都按预期工作。
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.
解决方案 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.
这篇关于MailSystem.NET主题编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!