Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Net.Mail and =?utf-8?B?XXXXX.... Headers

Tags:

People also ask

What does UTF-8 mean on mail?

UTF-8 is a variable-width character encoding used for electronic communication. Defined by the Unicode Standard, the name is derived from Unicode (or Universal Coded Character Set) Transformation Format – 8-bit.

Is UTF-8 a codepage?

UTF-8 is the universal code page for internationalization and is able to encode the entire Unicode character set. It is used pervasively on the web, and is the default for *nix-based platforms.

Does UTF-8 use 8bits?

UTF-8 is an 8-bit variable width encoding. The first 128 characters in the Unicode, when represented with UTF-8 encoding have the representation as the characters in ASCII.


I'm trying to use the code below to send messages via System.Net.Mail and am sometimes getting subjects like '=?utf-8?B?W3AxM25dIEZpbGV...' (trimmed). This is the code that's called:

MailMessage message = new MailMessage() {     From = new MailAddress("[email protected]", "Service"),     BodyEncoding = Encoding.UTF8,     Body = body,     IsBodyHtml = true,     ReplyTo = new MailAddress("[email protected]"),     SubjectEncoding = Encoding.UTF8 };  foreach (string emailAddress in addresses) {     message.To.Add(new MailAddress(emailAddress.Trim(), "Person")); }  message.Subject = subject; 

I'd like to emphasize that this does not happen all of the time.

What am I doing wrong?