Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question
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

1 Answer 1

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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