var emailFromAddress = _properties["EmailFromAddress"].ToString();
var emailToAddress = _properties["EmailDistributionGroup"].ToString();
var webAddress = _properties["WebSiteOfLibrary"].ToString();
var subject = "New Report - " + DateTime.Now.ToString("dd MMM yyyy");
StringDictionary messageHeader = new StringDictionary();
messageHeader.Add("to", emailToAddress);
messageHeader.Add("from", emailFromAddress);
messageHeader.Add("subject", subject);
messageHeader.Add("content-type", "text/html");
using (SPSite site = new SPSite(webAddress))
{
using (SPWeb web = site.OpenWeb())
{
DateTime timeNow = DateTime.Now;
var sb = new StringBuilder();
sb.Append(
"<STYLE TYPE='text/css'>body, html{font-color:#000;font-family:arial;font-size:8.0pt}</STYLE>");
sb.AppendFormat("<div style='font-size:11pt;font-family:calibri'>Results between {0} and {1}</div><br/><br/>", LastRun.ToString("dd MMM yyyy hh:mm tt"), timeNow.ToString("dd MMM yyyy h:mm tt"));
sb.AppendFormat("<div style='font-size:11pt;font-family:calibri'>Total: {0}<br/><br/>", total);
sb.AppendLine(HTMLResults);
SPUtility.SendEmail(web, messageHeader, sb.ToString());
}
}
Thursday, 6 September 2012
SpUtil.SendMail using Html body text
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment