5

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.

Jodrell
  • 34,946
  • 5
  • 87
  • 124
captivatedbyUBB
  • 153
  • 2
  • 9

1 Answers1

15

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.

Chris Moschini
  • 36,764
  • 19
  • 160
  • 190
Tomq
  • 1,085
  • 11
  • 14