我有一个包含超链接和richtextformat的列表字段。发送电子邮件我正在使用:

    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);
    });
.

它会发送超链接,但其余的是作为纯文本发送的。这是一个交换的结果,或者是richtext与html不一样吗?

有帮助吗?

解决方案

(字符串)listitem [“RichTextField”];与我的HTML标签返回,结果缺少我缺少的是一个额外的标题标记

    headers.Add("fAppendHtmlTag","True");
.

其他提示

试试这个

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

许可以下: CC-BY-SA归因
scroll top