Welcome to my personal blog, All the information in this bogs is my ideas,findings and thoughts on .Net, Asp.Net and SharePoint.
ALL POSTING ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
Note: Make sure that you have enabled search based alerts SSP-> Search Settings -> Search Based Alerts
1: SPSite spSite = new SPSite("http://nishand:300/sites/PubSite/Search/"); 2: SPWeb web = spSite.OpenWeb();
3: Query alertQuery = new KeywordQuery(spSite);
4: alertQuery.QueryText = "Hello" // Keyword
5: SearchAlert searchAlert = new SearchAlert(spSite, alertQuery);
6: searchAlert.InnerAlert.AlertFrequency = SPAlertFrequency.Daily;
7: searchAlert.InnerAlert.Title = "Alert#2"
8: searchAlert.InnerAlert.User = web.Users["domain\\user"];
9: searchAlert.Update();
How to check whether an alert named 'Alert#2' has been created?
Go to Site Actions -> Site Settings - User Alerts -> Select 'user name' and click on 'update' button.
Anonymous comments are disabled