Using the undocumented SPUtility.SendEmail method.

As with a lot of the sharePoint API, the SPUtility class and more importantly the sendEMail method lacks a decent amount of documentation on its use.

After a little bit of playing around with a console session, I’ve found what seems to be the best way to use this function. (For me at least.. feel free to disagree!!)

using System.Collections.Specialized;

For the purposes of my test code, I used a console sessions and wrapped the send email process inside two using statements to populate site and web with the test sharepoint site.

StringDictionary headers = new StringDictionary();
headers.add("subject","How to use SendEMail from SPUtility");
headers.add("content-type","text/html"); //This is the default type, so isn't neccessary.

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

SPUtility.SendEmail(web, headers, bodyText);

The SendEmail method makes it very easy to pop emails out using your SharePoint sites current SMTP configuration, the only downside is that this does not allow you to use attachments. If you need to do this, then you’ll need to look down the .Net mail methods.. (I found a decent post on David Fekkes blog on how to do this using the .Net methods. I haven’t tried it yet, but it’s a good starting point. Email with attachments from SharePoint code.


3 pings

Skip to comment form

  1. Hi. I have an excel workbook that uses VB to draw boxes representing the start time and end time of events. This provides a visual depiction of a scheduled flow. Is there a way to upload that VB into sharepoint (WSS or MOSS) and use a list that contains the same data, and draw the boxes? I can send the spreadsheet it that helps.

    Thank you

  2. Hi Ratzelda,

    You haven’t stated what version of excel you’re using, but I’m assuming it’s Excel 2003, in which case the code is written in VBA which wouldn’t work in SharePoint as it’s .Net based.

    If you wanted to re-create a similar effect you’d probably need to look at creating a webPart that would reference the list data and process it in a similar manner. Wether or not you could translate that into an HTML output or if you’d have to use a workspace to drop system.drawing info into I’m not sure. It’s not something I’ve tried in WSS.


  3. Hello!

    Is it possible to set not only the e-mail address in the from header but the name too? So that the from would look like this:

    like with MailMessage:

    MailMessage mail = new MailMessage();
    mail.From = new MailAddress( “”, “Name of Company”);


  4. Hi Tamás,

    Unfortunately the SPUtility.SendEmail isn’t very well documented (Hence the article title!), so I’m not sure how it would handle the format you propose.

    It’s meant to be a fairly simple implementation of SendMail so I wouldn’t imagine it will like recieving headers that don’t comply to the SMTP RFC.


  1. […] headers = new StringDictionary(); headers.add("to",""); headers.add("cc",""); […]

  2. […] Reference Link : […]

  3. […] This is an update of an earlier blog post that I wrote about using the SPUtility class and the SendEmail method, however instead of doing this in code, we’re going to use PowerShell. (This is the original blog post.) […]

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.