Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MailSystem.NET subject encoding

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.

like image 241
captivatedbyUBB Avatar asked Jul 17 '13 09:07

captivatedbyUBB


1 Answers

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.

like image 75
Tomq Avatar answered Sep 25 '22 06:09

Tomq