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:
Hi,

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

=?utf-8?B?VGhlIEZyb250IFBhZ2U6IFN0cmF0ZWd5OyBVdGlsaXRpZXM7IEJQQ0wgKEJVWSk7IEhQQ0wgKEJVWSk7IEdTSyBDb25zdW1lciAoQUREKTsgT2lsIEluZGlhIChCVVkpOyBIYXZlbGxzIEluZGlhIChCVVkpOyBCZXJnZXIgUGFpbnRzIChCVVkpOyBQYWdlIEluZHVzdHJpZXMgKFJFRFVDRSk7IFRhdGEgQ2hlbWljYWxzI


have used below code line in the email.

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


Pls do the needful.
Posted
Updated 24-Sep-20 21:55pm
v2
Comments
   
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.
—SA

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