1

I'm trying to write a new Email Event Receiver for an email-enabled document library. When my feature is disabled, email is delivered successfully to the library. When my feature is enabled, this appears in the UCS logs:

UCS Log

Loading and running the event receiver class MyEmailHandler.MyMetadataExtractionEventHandler.MyMetadataExtractionEventHandler from assembly MyEmailHandler, Version=1.0.0.0, Culture=neutral, PublicKeyToken=49f071f6ad2c11c6 failed. Object reference not set to an instance of an object.

EventReceiver

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

namespace MyEmailHandler.MyMetadataExtractionEventHandler
{
    public class MyMetadataExtractionEventHandler : SPEmailEventReceiver
    {
        public override void EmailReceived(SPList list, SPEmailMessage emailMessage, String receiverData)
        {
            base.EmailReceived(list, emailMessage, receiverData);
        }
    }
}

I'm new to SharePoint development so don't know what to do next to debug this. I tried following the instructions on this page under Debugging Feature Event Receivers and put the breakpoint on the base.EmailReceived(...) line, but the breakpoint was never triggered.

  • Which process are you attaching to debug code? you should not attach w3wp.exe instead you should attach owstimer.exe process to debug your receiver. (Note that you have deployed visual studio solution in debug mode) – Kalpesh Vaghela Jun 4 '15 at 4:09
2

follow these steps

1.Deploy your solution to SharePoint.

2.Press Windows+R and run Services.msc, Restart SharePoint Timer Service

3.Go back to visual studio attach process OWSTIMER.EXE and try sending mail to document library/list

NOTE: you will have to stop and start SharePoint Timer Service every time you deploy solution to Sharepoint.

when you send email check the drop folder (C:\inetpub\mailroot\Drop) does the mail gets stuck there?

  • Instead of sending email, I'm just copying and pasting an old .eml into the drop folder. It gets picked up after 30-60 seconds regardless of if my feature is enabled or not. I'll run through your steps later today and come back to share success or other issues. – bdx Jun 4 '15 at 23:35
  • sure let me know – Akshay Randive Jun 6 '15 at 5:12
  • These steps allowed debugging of the function in question. The error itself seems to be that the base.EmailReceived method is blank and isn't doing something that SharePoint expects it to. More details about this can be found here: blogs.msdn.com/b/malag/archive/2009/05/13/… – bdx Jun 8 '15 at 2:52
  • The relevant section of the blog link from my comment above: If you are planning to implement your own EmailHandler, you will need to take care of all the default functionality also provided by SharePoint, including checking user permissions, dealing with duplicate files, and saving the original email. – bdx Jun 8 '15 at 2:53

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.