locked
How To View All Alerts RRS feed

  • Question

  • Hi.

    Users have alerts set on multiple document libraries/lists etc. etc. across multiple SharePoint sites.

    How can I view all alerts for a specific user?

    How can I view all alerts for multiple users on a site/doc lib/list/etc.?

    This is for admin purposes but there doesn't seem to be an overall admin view.

    Thursday, August 16, 2012 8:36 AM

Answers

  • Hello,

    user the following code sample.

    First you need to get the all the user for the web then you need to get the all the alerts for all the uses by foreach(SPUser ....) loop.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    namespace Alerts
    {
    class Program
    {
    static void Main(string[] args)
    {
    using (SPSite site = new SPSite("http://serverName:22222/sites/TestSite/"))
    {
    using (SPWeb web = site.RootWeb)
    {
    SPUser user = web.EnsureUser(@"domainName\userName");
    SPAlertCollection alertColl = user.Alerts;
    foreach (SPAlert alert in alertColl)
    {
    Console.WriteLine(alert.Title);
    }
    Console.ReadLine();
    }
    }
    }
    }
    }

    OR

    private static void GetAlerts()
    {
    SPSite currSite = new SPSite(“http://server:port/”);
    SPWeb currWeb = currSite.OpenWeb();
    SPUserCollection collUsers = currWeb.Users;
    try
    {
    foreach (SPUser usr in collUsers)
    {
    Console.WriteLine(“Alerts for the User : “ + usr.Name);
    foreach (SPAlert alrt in usr.Alerts)
    {
    Console.WriteLine(alrt.Item.Title + ” –> “ + alrt.AlertFrequency);
    }
    }
    }
    catch
    {
    }
    Console.ReadLine();
    }
    }


    The same process you need to follow for the each subwebs and its user.


    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.




    • Edited by Hiren.j.Patel Thursday, August 16, 2012 8:47 AM
    • Marked as answer by Jack-Gao Friday, August 24, 2012 9:23 AM
    Thursday, August 16, 2012 8:42 AM

All replies

  • Hello,

    user the following code sample.

    First you need to get the all the user for the web then you need to get the all the alerts for all the uses by foreach(SPUser ....) loop.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SharePoint;
    namespace Alerts
    {
    class Program
    {
    static void Main(string[] args)
    {
    using (SPSite site = new SPSite("http://serverName:22222/sites/TestSite/"))
    {
    using (SPWeb web = site.RootWeb)
    {
    SPUser user = web.EnsureUser(@"domainName\userName");
    SPAlertCollection alertColl = user.Alerts;
    foreach (SPAlert alert in alertColl)
    {
    Console.WriteLine(alert.Title);
    }
    Console.ReadLine();
    }
    }
    }
    }
    }

    OR

    private static void GetAlerts()
    {
    SPSite currSite = new SPSite(“http://server:port/”);
    SPWeb currWeb = currSite.OpenWeb();
    SPUserCollection collUsers = currWeb.Users;
    try
    {
    foreach (SPUser usr in collUsers)
    {
    Console.WriteLine(“Alerts for the User : “ + usr.Name);
    foreach (SPAlert alrt in usr.Alerts)
    {
    Console.WriteLine(alrt.Item.Title + ” –> “ + alrt.AlertFrequency);
    }
    }
    }
    catch
    {
    }
    Console.ReadLine();
    }
    }


    The same process you need to follow for the each subwebs and its user.


    Hiren Patel | Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.




    • Edited by Hiren.j.Patel Thursday, August 16, 2012 8:47 AM
    • Marked as answer by Jack-Gao Friday, August 24, 2012 9:23 AM
    Thursday, August 16, 2012 8:42 AM
  • Hi,

     Please refer to this link about viewing Alerts Using Powershell:

    Viewing/Modifying Alerts Using Powershell

    Sharepoint 2010 Alert Controller

    Hope it can help.

    Best regards,

    Machindra Salunkhe

     
    Friday, August 17, 2012 7:11 AM