Click here to Skip to main content
14,981,456 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:

i have email service which is send to email to all users
some of the user getting below in the subject instead of correct subject


have used below code line in the email.

mailObj.SubjectEncoding = System.Text.Encoding.UTF8;
mailObj.BodyEncoding = Encoding.GetEncoding("utf-8");
mailObj.SubjectEncoding = Encoding.GetEncoding("utf-8");

Pls do the needful.
Updated 24-Sep-20 21:55pm
So what's the problem? This is correct subject, according to one of the mail-related standards/RFCs. This is UTF-8 encoding represented as base64 string. Perhaps "some of the users" use some stone-age mail application. Send a message with some Unicode characters to yourself and check up its presentation in your mail application.

Adding two whitespaces to the subject worked for me. Don't ask why.

var mail = new MailMessage(from, to);
mail.Subject = subject + new string(new char[] { '\u2000', '\u2000' });
mail.SubjectEncoding = Encoding.UTF8;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900