Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.
$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

share|improve this question
    
Just to double-check -Is the ItemAdded method you posted within the Microsoft.Office.Project.PWA.WSSEventReceivers.PS DBUpdater class? –  Ted N. Nov 2 '12 at 17:36
    
Hmm. I created it through VS2010 as a SharePoint thing. It is in the class: public class EventReceiver : SPItemEventReceiver { etc. } –  Oliver Nov 5 '12 at 9:06
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.