Delete all alerts programatically
Refer to blogs.msdn.com/dwinter/archive/2005/02/15/373076.aspx for setup if you are not familiar with creating a SharePoint OM application.
This is a simple example of removal of all alerts registered in a site. This can be handy for testing or mass cleanup.
private
void button1_Click(object sender, System.EventArgs e)
{
//delete all alerts in entire site
using(SPSite mysite = new SPSite(this.textBox1.Text))
{
foreach (SPWeb myWeb in mysite.AllWebs)
{
foreach(SPAlert myAlert in myWeb.Alerts)
{
try
{
myWeb.Alerts.Delete(myAlert.ID);
}
catch (Exception ex)
{
this.textBox2.Text = ex.Message+"\nError deleting "+myAlert.User.LoginName+" Alert:" + myAlert.ListUrl;
}
}
}
}
}
It would be easy to modify this code to clean a single user out of every site if you put an if statement such as the following in the last foreach loop:
if (myAlert.User.LoginName == textbox3.Text)
Comments
- Anonymous
February 16, 2005
http://blogs.msdn.com/dwinter/archive/2005/02/16/375021.aspx
Ein Codeschnipsel um alle Benachrichtigungen aus einer SharePoint Site zu l - Anonymous
February 16, 2005
http://blogs.msdn.com/dwinter/archive/2005/02/16/375021.aspx
Ein Codeschnipsel um alle Benachrichtigungen aus einer SharePoint Site zu l - Anonymous
April 04, 2008
PingBack from http://www.justaddcode.com/blog/2008/04/03/deleting-sharepoint-site-alerts/