Using CSOM, I am able to retrieve the collection of alerts for a SharePoint Online site and disable each alert using the following code:
context.Load(context.Web.Alerts,
collection => collection.Include(
alert => alert.ID,
alert => alert.Status));
context.ExecuteQueryWithRetry();
foreach (SP.Alert alert in context.Web.Alerts)
{
if (alert.Status == AlertStatus.On)
{
context.Load(alert);
alert.Status = AlertStatus.Off;
alert.UpdateAlert();
}
}
context.ExecuteQueryWithRetry();
This doesn't work for SharePoint 2013 though. I get the error: "Field or property 'Alerts' does not exist". Can this be done with CSOM?