Monday, December 12, 2011

Sharepoint 2010 - Email Event Receiver Issues

The Email event receiver is not so simple to create and execute...
I experienced some issues for the correct configuration.

EmailReceived Method: wrong reference in Handle Email Receiver method created by VS
When you create the email event receiver you see the method EmailReceived. In Visual Studio, see properties of event receiver and you see "handle email receiver" = false.
If you set to true, VS creates method EmailReceiver with Microsoft.Sharepoint.SPEmailMessage insthead of Microsoft.Sharepoint.Utilities.SPEmailMessage.
This cause error in build event receiver.
I think is an issue/bug of Sharepoint 2010, but I did not found any documentation in MS.
Solution: The event receiver work fine without set "handle" property to true. Leave this setting to false.

Email Event Receiver: SPContext.Current is null
Solution: use list.ParentWeb, from the list property of method EmailReceived.

Email Event Receiver: if you have to process attachment of email
If your Email ER processes attachments and in Incoming Email Settings you configured for saving only attachments, but not email message, the ER fails to load.
Solution: go to Incoming Email Setting and set "Save original Message email"

Incoming Email Settings: you don't see all properties (Email Attachments, Email Message, Email Security, ecc)
If you attach Email Event Receiver, you will see only setting for email address of incoming email for Document Library.
Solution: Deactivate custom feature for Email ER, set your Incoming Email Settings, then activate feature.

Deploy Event Receiver and ER don't fires
I created, built and  deployed my email event receiver. Library is correctly configured to receive email with attachment. But when I send mail, there's no mail or data in document library.
Solution: when you deploy and IIS resets, restart Sharepoint Timer Service (from services.msc). Then send mail and all works fine.

Have you found other issues and have you resolved them?
Write me!

No comments:

Post a Comment