Search code examples
c#.netemailmailsystem.net

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.


Solution

  • 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.