Customizing SP2010 OOB alert emails template.
Steps to customize SP2010 OOB alert emails:
1. Create copy of existing alerttemplates.xml file
2. Create custom alert template in Customalerttemplates.xml file
3. Update Customalerttemplates.xml file in contentdb
//below code sets the alerttemplatetype to the main list
// this template is specified in customalerttemplates.xml file
SPAlertTemplateCollection atc = new SPAlertTemplateCollection((SPWebService)site.WebApplication.Parent);
SPAlertTemplate newTemplate = atc["WorkflowSuite_CustomTemplate"];
if (newTemplate == null)
{
throw new Exception("Alert Template not found");
}
else
{
list.AlertTemplate = newTemplate;
list.ParentWeb.AllowUnsafeUpdates = true;
list.Update();
}
==============================
Note: This step ensures that our only our list (SP list specified in the code above) is pointing to the custom template !
1. Create copy of existing alerttemplates.xml file
- Make copy of alerttemplates.xml file and rename it in the same location @ C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML
- Say you rename the file as – Customalerttemplates.xml
2. Create custom alert template in Customalerttemplates.xml file
- Select appropriate template in the file and copy it
- Rename the new template with unique name – say WorkflowSuite_CustomTemplate
- Do required changes in the above template
3. Update Customalerttemplates.xml file in contentdb
- STSADM -o updatealerttemplates -url
-filename "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\Customalerttemplates.xml" -lcid 1033
This command updates the xml file in contentdb. This sharepoint timer job refers to the updated file. - Reset IIS
- Restart sharepoint timerjob service.
- net stop SPTimerV4
- net start SPTimerV4
Note: This step needs to be repeated after every single change we make in the Customalerttemplates.xml file.
- Update the SP List to point to our custom alert template that we created in Customalerttemplates.xml
//below code sets the alerttemplatetype to the main list
// this template is specified in customalerttemplates.xml file
SPAlertTemplateCollection atc = new SPAlertTemplateCollection((SPWebService)site.WebApplication.Parent);
SPAlertTemplate newTemplate = atc["WorkflowSuite_CustomTemplate"];
if (newTemplate == null)
{
throw new Exception("Alert Template not found");
}
else
{
list.AlertTemplate = newTemplate;
list.ParentWeb.AllowUnsafeUpdates = true;
list.Update();
}
==============================
Note: This step ensures that our only our list (SP list specified in the code above) is pointing to the custom template !
Comments
Post a Comment