I have a massive problem that I need to solve. I have a document library that is a catch all dumping ground for emails that are forwarded there by our users out in the field. With in these emails are signatures that will have the original persons email address in, the domain in that address has a discussion board related to it.

So for example Gmail.com has one where I want to put all the address with that domain into one discussion board.

So far I have the following code:

    using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Security;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;

namespace EventReceiverProject1.EventReceiver1
    /// <summary>
    /// List Email Events
    /// </summary>
    public class EventReceiver1 : SPEmailEventReceiver
       /// <summary>
       /// The list received an e-mail message.
       /// </summary>
       public override void EmailReceived(SPList list, SPEmailMessage emailMessage, String receiverData)
           SPListItem oListItem = list.Items.Add();
           oListItem["Title"] = emailMessage.Headers["Subject"];
           oListItem["Body"] = emailMessage.HtmlBody;


But I'm not sure how I define it and where to put it based on the domain. Here is an example list:

DOMAIN gmail.com, hotmail.com
DISCUSSION BOARD Gmail customers, Hotmail Customers

Any help on this would be a massive help!


  • sorry, am not 100% sure about what your asking for but Custom Column might be the answer ? – tereško Aug 29 '12 at 11:14
  • Pretty much I need to copy an email that comes into the catch all document library and place it into its correct customer discussion board. Based on an email address it finds inside of an email. – niceNmilky Sep 3 '12 at 13:13

The only solution for this is to write a parser, that will search for forwarded e-mail header in the e-mail content (HtmlBody) and extract original persons e-mail address. It is really a complicated task.

You can search for header markers generated by e-mail client which has forwarded e-mail to your system. Then parse header name / values:

From: address

Sent: date

To: address

Subject: text

Take To or From addresses and make a decision where to put e-mail.

If you have a predefined set of domains for e-mail addresses then you can simplify solution by using regular expressions to check if e-mail body contains e-mail addresses from that domain.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.