[Sharepoint Tip] Create alerts programatically#

In some cases you want a user to automatically create alerts on particular lists, for example an action list. It's very easy to achieve that:

SPWeb thisWeb = SPControl.GetContextWeb(Context);
thisWeb.AllowUnsafeUpdates = true;    
SPList myList = thisWeb.Lists["[list name]"];
// in this case a daily alert on all list actions
thisWeb.CurrentUser.Alerts.Add( myList,SPEventType.All,SPAlertFrequency.Daily);
thisWeb.CurrentUser.Update();

The same way, alerts can be added for list items. 

Thursday, April 14, 2005 7:34:27 AM UTC #    Comments [0]  |  Tracked by:
"Great Tip about creating alerts programatically" (Alex's blog about SharePoint ... [Trackback]

 

All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview
All content © 2010, Mart Muller
On this page
This site
Calendar
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
Archives
Sitemap
Disclaimer

Powered by: newtelligence dasBlog 1.9.7174.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts