SPContext.Current.Web
(1)
SPUtility.SendEmail
(1)
SPUtility.SendEmail.
(1)
SPUtility
(1)
Visual Studio 2008
(1)
SharePoint
(1)
ISFeedbackSurvey
(1)
PublicKeyToken
(1)

EventReceiver not working

Asked By Nik
17-Nov-09 03:23 PM
Using Visual Studio 2008, with VSeWSS3, I have created a new empty SharePoint
project (to GAC), then added new item > event receiver to Survey list type.

then added to the ItemAdding the following line of code:

SPUtility.SendEmail(SPContext.Current.Web, false, false,
result of the event ItemAdding firing on the survey");

Built and deployed the solution from the menu. I was expecting this to work,
but it is not firing, and in the logs I get:

Error loading and running event receiver
ISFeedbackSurvey.ISFeedbackSurveyEvtItemEventReceiver in ISFeedbackSurvey,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=97efffa28708eee2. Additional
information is below.  : Object reference not set to an instance of an object.

and

Event manager error: Could not load file or assembly 'SurveyNotification,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=4884dab2ea11612f' or one of
its dependencies. The system cannot find the file specified.

I have checked the GAC, the dll is there, the SafeControls entry is in the
web.config...

What am I missing?

Funny enough, the coding in ItemDeleting is firing just fine.

Did some more investigation, if I put something as simple asproperties.

Nik replied to Nik
18-Nov-09 08:38 AM
Did some more investigation, if I put something as simple as

properties.ErrorMessage = "Hitting ItemAdding event override...";
properties.Cancel = true;

it works just fine. Those errors are in fact thrown by SPUtility.SendEmail...

how do I go about using SPUtility? What else needs to be deployed with my
feature?

Solved it by using System.Net.Mail instead.

Nik replied to Nik
25-Nov-09 09:14 AM
Solved it by using System.Net.Mail instead. Will go back to SPUtility at a
later time to investigate.
Post Question To EggHeadCafe