On SharePoint 2013, we are using mail-enabled announcements lists to collect incoming emails.

We need to extend the built in functionality with our custom code (store the message in our own database, along with From and To-address). This leads us to using either SPItemEventReceiver or SPEmailEventReceiver.

With SPItemEventReceiver, we can do our extended processing in the ItemAdded override. Also, we get lots for free:

  • The incoming mails will automatically be stored in the list
  • The original message (original.eml) will be added as an attachment
  • From, To, CC will be extracted, etc.

With SPEmailEventReceiver, SPItemEventReceiver.EmailReceived will be called, but we have to take care of storing the message, extract the values, etc in the list ourselves. In other words, more work and more code to maintain.

There's one little gotcha, though. SPItemEventReceiver is not email-specific, and there no mail-properties, such as "Sender" etc. Instead, in SPItemEventReceiver.ItemAdded, we retrieve SPItemEventProperties, and we extract "EmailFrom", "EmailTo" etc from its Fields collection.

However, these values seem to be "polluted" in order to be shown in the SharePoint UI. E.g., "EmailFrom" and "EmailTo" have this form:

"DisplayName <email-address>"

For Example:

"John Doe <john@doe.se>"

And that's not what we want. Of course, we could parse out the real email-address, but that seems clumsy.

So, my question is: Is there anyway to extract the "raw" email properties, such as From and To address using SPItemEventReceiver? Or should we use SPEmailEventReceiver (with the extra work it involves)?

Thanks! /Fredrik


It would be better to use SPItemEventReceiver and use a .NET class that can help you with the clumsy parsing. It is called called MailAddress.

Please see StackOverflow question here:


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.