Monday, May 23, 2011

Send an email with html format using SPUtility.SendEmail

SPWeb oWeb = SPContext.Current.Web

StringDictionary headers = new StringDictionary();

headers.Add("from",  "");
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("<br><br><b>Login Instructions: </b><br>");
strMessage.Append("<font color='red'><UL><li>If you are a US employee ALWAYS login in using the following login format </font><br>");

SPUtility.SendEmail(web, headers,strMessage.ToString());


  1. How can I add attachment in this case? I am using embed image concept and I need to embed an image in my email.

    1. Did you try using < img > tag? having the image in the SharePoint site?