[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 content © 2010, Mart Muller
On this page
This site
Calendar
<July 2010>
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
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