Home > ASP.NET, C#, MOSS 2007, SharePoint > How To: Enable Incomming emails on a Custom SharePoint List

How To: Enable Incomming emails on a Custom SharePoint List


First of all if this list is hosted in a Meeting Workspace Web then this will not work. Please refer to this post for complete details.

Briefly, this is what you need to do:

  • Create your custom SharePoint list
  • Attach an Event handler of type ‘EmailReceived’ to your list (once you do this the ‘Incoming Email Settings’ option will appear in the List Settings section of the site)
  • Add some code to your event handler as per your requirements to process the email
  • Deploy your list the usual way and create an instance of it (could be done as part of the deployment or via the UI)

In the example below I am picking up the subject of the email, creating a new list item where I set the title field value to match the subject. This is a very simple example but you can do a whole lot of stuff in this event handler such as processing attachments e.t.c.

public override void EmailReceived(SPList list, SPEmailMessage emailMessage, String receiverData)
{
    SPListItem newItem = list.Items.Add();
    newItem["Title"] = emailMessage.Headers["subject"]
    newItem.Update();
}

For complete details on how to configure your environment to facilitate processing of incoming emails please click here or here. There is also a very useful technet video on the subject here.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: