Send Email using SPUtility Class

The SPUtility.SendEmail method enables you to send an email from the context of a SharePoint Web (SPWeb) object.
There are four overloaded methods that support different parameter lists.
The following is the one of the methods to send e-mail notification to a specified address.

Syntax:

SPUtility.SendEmail(Parameter1, Parameter2, Parameter3, Parameter4, Parameter5, Parameter6);


Parameter1  - web(SPWeb)
Parameter2  - AppendHtmlTag(boolean)
Parameter3  - HtmlEncode(boolean)
Parameter4  - Recipient Email Address(String)
Parameter5  - Mail Subject(String)
Parameter6  - Message(String)

The following code sample show how to use the SPUtility.SendEmail method.

// Namespace for SPUtility
using System.Web.Mail;
using Microsoft.SharePoint.Utilities;

SPWeb web = SPContext.Current.Web;
bool success = SPUtility.SendEmail(web, true, true, "admin@myserver.com", "TestMail", "This is a Sample Mail.");

This will send a mail to “admin@myserver.com”, with “TestMail” as subject and “This is a Sample Mail.” as body.