2

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","[email protected]");
    headers.add("from","[email protected]");
    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?

2 Answers 2

1

(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");
0

try this

SPField field = listitem.Fields["RichTextField"];
string body= field.GetFieldValueAsHtml(listitem["RichTextField"]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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