fbpx

Sending email is a key function of enterprises solutions. Inside SharePoint collaboration environment you always need to send email from within SharePoint. For this purpose you can use SPUtility class SendEmail method.

Below is a simple example code for sending email using SPUtility.

Add namespace reference:

Microsoft.SharePoint.Utilities
//Code:
private viod SendEmail()
{
  try {
    SPSecurity.RunWithElevatedPrivileges(delegate()
    {
      using (SPSite site = new SPSite(SPContext.Current.Site.ID,
      SPContext.Current.Site.Zone))
      {
        using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
        {
         SPUtility.SendEmail(web, true, true, "info@eblogin.com",
         "Subject", "Your message body will go here");
        }
      }
    });
  }
  catch (Exception ex) {}
}

As you can see that sending email using SPUtility is straightforward, please also note the following considerations

1.   No attachment allowed

2.   Message body size cannot exceed 2048 characters.

3.   The form address will be the “Outbound Sender Address” configured in the central admin.

4 Comments

Comments are closed.

About Us

Follow Us

Email: contact@keapoint.com
Phone:  0208 7852 888

Registered Address: 1 Amber Close, Reading, RG6 7ED. United Kingdom

Company No. 11586817