Question

$web = Get-SPWeb "http://----/PWA/Test Project/"
$list = $web.Lists["Risks"]
$list.EventReceivers

This shows 3 events; ItemAdded, ItemDeleted, ItemUpdated. Below is an example of one of them to show its there.

Id                          : xxxxx-96a1-4e1c-acbd-c98cd8d16e19
Name                        : ItemAddedEventReceiver
SiteId                      : xxxxx-a858-443f-8159-6a6e33758693
WebId                       : xxxx-f09b-4f3a-be28-1d5f6a158ac1
HostId                      : xxxxx-1d5a-4e5c-8fa9-d3615d33b315
HostType                    : List
ParentHostId                : 00000000-0000-0000-0000-000000000000
ParentHostType              : Site
Synchronization             : Asynchronous
Type                        : ItemAdded
SequenceNumber              : 4000
Assembly                    : Microsoft.Office.Project.Server.PWA,Version=14.0.
                              0.0,Culture=neutral,PublicKeyToken=71e9bce111e942
                              9c
Class                       : Microsoft.Office.Project.PWA.WSSEventReceivers.PS
                              DBUpdater
Data                        :
Filter                      :
Credential                  : 0
ContextItemId               : 0
ContextItemUrl              :
ContextType                 : 00000000-0000-0000-0000-000000000000
ContextEventType            : 00000000-0000-0000-0000-000000000000
ContextId                   : 00000000-0000-0000-0000-000000000000
ContextObjectId             : 00000000-0000-0000-0000-000000000000
ContextCollectionId         : 00000000-0000-0000-0000-000000000000
UpgradedPersistedProperties :

If I run in debug mode the breakpoint never hits (I turned off auto activate, set breakpoints, deployed, activated feature, tried adding and then deleting).

   public override void ItemAdded(SPItemEventProperties properties)
   {
       MailMessage mailMessage = new MailMessage();
       mailMessage.Bcc.Add(new MailAddress(".@.com"));
       mailMessage.From = new MailAddress(".@.com");
       mailMessage.Subject = "Boom Risk";
       mailMessage.Body = "test body";

       var smtpClient = new SmtpClient
       {
           Host = "smtp.hhhhh.com",
           Port = 25,
           Credentials = new NetworkCredential
               ("", "")
       };

       smtpClient.Send(mailMessage);

       base.ItemAdded(properties);
   }

That is the code.

Can anyone suggest why it may not be working?

Thanks

Was it helpful?

Solution

Well after all that....

As I am on Project Server I had been deploying to the PWA. Turns out I have to deploy to every individual Project Site. Once I deployed to one of these it worked!

Hoorah.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top