1

I would like to know when and how many SPAlerts are sent to a specific user, is there any way to do this?

ShareBear
  • 133
  • 2
  • You need to clarify as one alert can send many emails - so are you asking how many emails all alerts have been sent to a user or how many alerts a user is signed up to? – Ryan Jan 12 '11 at 12:54

2 Answers2

2

Easiest way is probably just inspect your mail server logs.

The alerts are just fired out by timerjobs, not sure if it logs how many & to whom they were sent.

James Love
  • 25,512
  • 2
  • 45
  • 77
1

here is the code to achieve it:

SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSite.AllWebs;
foreach (SPWeb oWebsite in collWebsites)
{

    SPAlertCollection collAlerts = oWebsite.users["LoginName"].Alerts;    
    foreach (SPAlert oAlert in collAlerts)
    {
        //do something
    }
    oWebsite.Dispose();
}    
Falak Mahmood
  • 17,298
  • 2
  • 40
  • 67