Scenario:
You have a special list and you want to use unique email alert template for that list.
Solution:
You need to edit the AlertTemplates.xml file to include the new template which you want to use with a unique name and then you can programatically set this specific alert template for any particular list. Assuming you have created a new alert template in AlertTemplates.xml with the name 'AlertTemplate.SpecialList'.
Code:
using(SPSite site = new SPSite("http://localhost")){Article:
using(SPWeb web = site.Open.RootWeb){
SPList = web.Lists["SpecialList"];
SPAlertTemplateCollection ats = new SPAlertTemplateCollection((SPWebService)(WebApplication.Parent));
//give appropriate values for WebApplication
list.AlertTemplate = ats["AlertTemplate.SpecialList"];
list.Update();
}
}
All about sharepoint alerts , MSDN , Pre Defined Templates
2 comments:
Hello
Where do I run this code? In Powershell?
I kept it generic , as this code need to be run only one time....
you can use it in console application / feature receiver
Post a Comment