开发者

Question - Should I use SPItemReceiver or SPEmailEventReceiver

I have custom SharePoint Document Library which I use to upload spreadsheet data into a database. When a spreadsheet is uploaded, the SPItemReceiver triggers, and upload the data. Now, I would like to add an incoming email feature to the document library.

My question is...after the document library has received the spreadsheet by email. Should I use the override-able method EmailReceived of the SPEmailEventReceiver to process the data in开发者_StackOverflow the spreadsheet or still use the SPItemReceiver?

I gather I could use either, but I would like to know your opinion which is better and why.

Thanks in advance


You should use SPEmailEventReceiver to process the data. This will make it easy for you to maintain your code and debug. Below is the sample code to process the data. In this code itself, you can include the code to upload the data into database.

public class EmailHandler: SPEmailEventReceiver
{
public override void EmailReceived(
SPList objList,
SPEmailMessage objMessage,
string strReceiverData)
{
SPListItem objListItem = objList.Items.Add();
objListItem["Title"] = objMessage.Headers["Subject"];
objListItem["Body"] = objMessage.HtmlBody;
objListItem.Update();
}
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜