Share via


Sending Email From SharePoint

One of the pretty common things you might need to do in a SharePoint application is to send an email.  Since SharePoint has SMTP already configured this becomes pretty simple via the leveraging of the SharePoint Utilities API.  These utility methods are especially useful for things like sending emails or converting Dates in SharePoint.  Below is a snippet of what is needed to send an  Email.  Simply make the reference to the SharePoint.dll in your project and add the “Using” statement at the top of your file.  Then it is just a matter of calling the right method!  That’s it!

 Add one of the following to the top of your class file: 
 using Microsoft.SharePoint.Utilities; (C#)
 OR
 Imports Microsoft.SharePoint.Utilities (VB)
 Then call the method from your code: 
SPUtility.SendEmail(SPContext.Current.Web, false, false,"to-address@mail.com", "E-mail title", "E-mail body");

Comments

  • Anonymous
    September 23, 2010
    We are on Explorer 6, but I have heard you must be on Explorer 7 to send mail (not alerts) from Sharepoint.  Is that true?

  • Anonymous
    January 26, 2011
    This method is strickly done in code so there is not borwser requirement.  As for sennd emails using the SharePoint UI, please not that IE6 is NOT supported in SharePoint 2010 and basdly in IE6.  

  • Anonymous
    February 16, 2011
    I've been trying to get SharePoint 2007 to send email via timer job for several days now and am finally going out to the internetz for help. The timer job is installing a successfully running every 5 minutes. However, I am not receiving any emails. Here is the code that I am using.                       SmtpClient smtp = new SmtpClient(this.WebApplication.OutboundMailServiceInstance.Server.Address);                        smtp.UseDefaultCredentials = (smtp.Credentials == null);                        MailMessage message = new MailMessage("email@email.com", "email@email.com");                        smtp.Send(message);