Wednesday, June 15, 2011

Send an email with html format using SPUtility.SendEmail

Send an email with html format using SPUtility.SendEmail
using this Namespace
using System.Text;
using System.Collections.Specialized;


SPWeb oWeb = SPContext.Current.Web

StringDictionary headers = new StringDictionary();

headers.Add("from", "system@domain.com");
headers.Add("to", spUser.Email);
headers.Add("subject", "Welcome to the SharePoint group: ABC site: ");
headers.Add("content-type", "text/html"); //This is the default type

System.Text.StringBuilder strMessage = new System.Text.StringBuilder();
strMessage.Append("Login Instructions:");
strMessage.Append("< span style='color:red; '> you are a US employee ALWAYS login in using the following login format< /span >");
SPUtility.SendEmail(web, headers,strMessage.ToString());

Best of Luck

No comments: