Asp.net C # Special Character Email Address

I send emails with built-in System.Net.Mail

I like

MailAddress abs = new System.Net.Mail.MailAddress(" my@email.com ", "Web PrΓ€senz", System.Text.Encoding.UTF8); 

when e-mail arrives at the client, the β€œΓ€β€ symbol is absent. seems like some coding issues.

Does anyone know how to fix this?

+4
source share
2 answers

try adding them too:

 message.BodyEncoding = System.Text.Encoding.UTF8; message.SubjectEncoding = System.Text.Encoding.UTF8; 

This may be a problem with the mail server. Try sending it to a different email address; POP3, WebMail, etc.

There is more information here, although you probably already looked here:

http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient.aspx

+4
source

I just spent 5 hours debugging a similar problem, and the solution I found might be the solution to this problem. Since no one posted any other solutions, I will make my conclusions.

There is a subtle error in the .NET2.0 Mail API, which causes the encoding of recipient names in message headers to fail. This happens if the To object (and possibly others) of the MailMessage instance is accessed before the message is sent.

In the following example, the To header will be sent without encoding, which will cause at least my mail client to display the name as "?????? ...":

 MailMessage message = new MailMessage(); message.To.Add(new MailAddress(" address@example.com ", "Γ†Γ˜Γ… Unicode Name")); message.Subject = "Subject"; message.Body = "Body"; Console.WriteLine(message.To[0]); smtpClient.Send(message); 

However, moving the WriteLine under the send line causes the To header to be correctly encoded:

 MailMessage message = new MailMessage(); message.To.Add(new MailAddress(" address@example.com ", "Γ†Γ˜Γ… Unicode Name")); message.Subject = "Subject"; message.Body = "Body"; smtpClient.Send(message); Console.WriteLine(message.To[0]); 

I assume that this error will be in the properties of Cc and Bcc, so beware of this. Hope someone finds this helpful.

+2
source

All Articles