Monday, January 3, 2011

creating Folders within SharePoint List Programmatically

using (SPSite sSite = new SPSite("http://yourservername"))
{
using (SPWeb sWeb = sSite.OpenWeb())
{
SPUser sUser = sWeb.SiteUsers["domainname
\\username"];
SPAlert sListAlert =
sUser .Alerts.Add();

//Define the type of object
sListAlert.AlertType = SPAlertType.List;
// the List or Document Library to which alert is applied
sListAlert.List = sWeb.Lists["List_Name"];
//Define the Event type
sListAlert.EventType = SPEventType.All;
//Set time interval for sending alert.
sListAlert.AlertFrequency = SPAlertFrequency.Immediate;

//Pass true to Update method will send confirmation mail
sListAlert.Update(false);

//Dispose objects
sListAlert = null;
sUser = null;
}
}

No comments:

Post a Comment