1
votes

I am creating an email event receiver for sharepoint 2010 for a document library that receives emails in and I want to be able to then copy those emails that are sent to that list to another one. Now how would I go about doing that using an email event receiver rather than a itemAdded event receiver? what object methods can I use to get a copy method to another list etc?

1
SPEmailEventReceiver (if not in a sandbox) or with the ItemAdded you just check the "To" property for a value.Paul Leigh
yes i am using SPEmailReceiver and the EmailReceived method within that but how do i copy an item to another list as their are no copy to methods within SPEmailRecieveduser1063793

1 Answers

3
votes

SPEmailEventReceiver has the EMailReceived method.

When you take the MSDN example code:

public class Email_Handler: SPEmailEventReceiver
{
    public override void EmailReceived(
        SPList oList,
        SPEmailMessage oMessage,
        string strReceiverData)
    {
        SPListItem oListItem = oList.Items.Add();
        oListItem["Title"] = oMessage.Headers["Subject"];
        oListItem["Body"] = oMessage.HtmlBody;
        oListItem.Update();
    }
}

You see that they add the list item to the list via oList.Items.Add() which is exactly what you can do. You could also add the item to any other list.

Once you have the list item you could copy it to any other list by using the SPListItem.CopyTo method.

A good example for an EMail event receiver: http://pholpar.wordpress.com/2010/01/13/creating-a-simple-email-receiver-for-a-document-library/