Click here to Skip to main content
13,799,517 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


3 bookmarked
Posted 6 Aug 2013
Licenced CPOL

How to send email in SharePoint?

, 6 Aug 2013
Rate this:
Please Sign up or sign in to vote.
How to send email in SharePoint.


I am not sure why but Microsoft does it every time. They give you a piece of functionality but leaves you struggling with a certain and so called 'known' limitation.

One such limitation is sending emails when using SharePoint. SharePoint provides an API called 'SPUtility.SendEmail' to send emails. But the implementation of this API seems to be incomplete. If you notice the method, it is impossible to send an email with an attachment or to change the from address of the sender (from address can be added as a header, thanks to Giacomo for pointing out). 

Using the code 

To make thing simpler, you can use the following class to extend the functionality and use the good old MailMessage object to send email (without any extra infrastructure configuration). 

public class SMTPHelper
    private readonly string _specifiedPickupDirectory = string.Empty;
    private readonly SmtpClient _smtpClient;

    public SMTPHelper(string specifiedPickupDirectory)
        _specifiedPickupDirectory = specifiedPickupDirectory;

        _smtpClient = new SmtpClient();
        if (string.IsNullOrEmpty(_specifiedPickupDirectory))
            //Get the Sharepoint SMTP information from the SPAdministrationWebApplication
            var host = SPAdministrationWebApplication.Local.OutboundMailServiceInstance.Server.Address;
            _smtpClient.Host = host;
            _smtpClient.PickupDirectoryLocation = _specifiedPickupDirectory;
            _smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;

    public void SendEmail(MailMessage mailMessage)

The above code basically make use of the OutboundMailServiceInstance to retrive the SMTP server address configured within SharePoint. Generally, you can configure this address in Central Administration -> System Settings -> Configure outgoing e-mail settings.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Manas Bhardwaj
Netherlands Netherlands

Read my personal blog at

You may also be interested in...

Comments and Discussions

QuestionThanks, but missing a piece Pin
B. Clay Shannon28-Jul-15 8:47
professionalB. Clay Shannon28-Jul-15 8:47 
QuestionSPUtility.SendEmail() Pin
Giacomo Pozzoni6-Aug-13 7:35
memberGiacomo Pozzoni6-Aug-13 7:35 
AnswerRe: SPUtility.SendEmail() Pin
Manas Bhardwaj6-Aug-13 8:40
professionalManas Bhardwaj6-Aug-13 8:40 
AnswerRe: SPUtility.SendEmail() Pin
Manas Bhardwaj6-Aug-13 8:44
professionalManas Bhardwaj6-Aug-13 8:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.181207.3 | Last Updated 6 Aug 2013
Article Copyright 2013 by Manas Bhardwaj
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid