Is it possibile to send an html email encoded in utf-16 with sharepoint 2010? My problem is that I have a message body wich can contain accented characters which on the receiving end are displayed wrong. I suppose this is because c# stores strings in utf-16 but sharepoint sends them in utf-8.

This is the code I'm using to send these emails:

StringDictionary headers = new StringDictionary();

headers.Add("to", user.Email);
headers.Add("from", "no-reply@domainname.com");
headers.Add("subject", oggetto);
headers.Add("content-type", "text/html"); 

SPUtility.SendEmail(mySite, headers, messaggio);

I tried also:

headers.Add("content-type", "text/html; charset:utf-16"); 

But in the headers of the email I get

text/html; charset:utf-16; charset=utf-8

So no luck for me.

Any idea?

  • 1
    don't know if there is a better solution, but you can still extract the SMTP server from the SPWebApplication object, and use the standard System.Net.Mail.* classes – Steve B Jul 6 '12 at 14:12
  • So, if you change encoding in your mail client to utf-8, is text displayed successful? I suppose that charset specifies how it should be displayed by mail client. – muradovm Jan 29 '13 at 7:19

Instead of using UTF-16 which seem difficult, you could replace your accented characters with the equivalent utf-8-safe numerical code. This would look like the the following:

string body = messageBody.Replace("à", "à");
body = body.Replace("á", "á");

This will effectively give your html-email-body the correct character encoding and would be displayed correct when viewed as a html message.

List: HTML Codes - HTML Special Characters

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.