How to read Alerts for a specific user using CSOM in SharePoint online/Office 365?

Hello Sharepointers,

Below is the sharepoint CSOM code to get list of alerts for a given User. The below CSOM code will give you alert ID, alert Title and its Name.

string UserName = “i:0#.f|membership|” + userName;
User user = site.EnsureUser(UserName);
AlertCollection alerts = user.Alerts;
context.Load(alerts);
context.ExecuteQuery();
Console.WriteLine(alerts.Count);
foreach (Alert alert in alerts)
{
Console.WriteLine(“Alert ID: {0}\n Alert Name:{1} “, alert.ID,alert.Title);
}

Happy SharePointing 🙂

Leave a Reply

Your email address will not be published.