Sending richText format in email (currently using SPUtility.sendemail)
Question
I have a list field that contains hyperlinks and richtextformat. To send the email I am using:
Spweb web = spcontext.current.web;
StringDictionary headers = new StringDictionary();
headers.add("to","someone@email.com");
headers.add("from","me@rmail.com");
headers.add("subject","helloWorld");
headers.add("content-type","text/html"); //default
string body = (string) listitem["RichTextField"];
SPSecurity.RunWithElevatedPrivileges(delegate(){
SPUtility.SendEmail(web, headers, body);
});
It sends the hyperlinks fine but the rest is sent as plain text. Is this a result of Exchange or is RichText not the same as HTML?
Solution
(string)listitem["RichTextField"]; does return with html tags for me, turns out what I was missing was an additional header tag
headers.Add("fAppendHtmlTag","True");
OTHER TIPS
try this
SPField field = listitem.Fields["RichTextField"];
string body= field.GetFieldValueAsHtml(listitem["RichTextField"]);
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange