Blast From The Past : SPUtility.SendMail() in SharePoint

I used to do buttloads of SharePoint development since 2007 to 2013. One of the stuff I used a lot and an now putting it here so I remember it is the SPUtility.SendMail() function. It basically one of those undocumented features that I used a lot. It may be documented now but here is goes anyway:

var headers = new StringDictionary();
headers.add("to","admin@test.com");
headers.add("cc","manager@test.com");
headers.add("bcc","user@test.com");
headers.add("from","myAddress@test.com");
headers.add("subject","How to use SendEMail from SPUtility");
headers.add("content-type","text/html"); //This is the default type, so isn't neccessary.

var bodyText ="This is the body of my email, in html format.“;

SPUtility.SendEmail(web, headers, bodyText);

This will enable you to send an email with the SMTP server you configured in on SharePoint Central Administration.

MSDN Link:

  1. http://msdn.microsoft.com/en-us/library/ms454274.aspx
  2. http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail.aspx

Hope this helps.