Customizing SP2010 OOB alert emails template.

Steps to customize SP2010 OOB alert emails:

1.       Create copy of existing alerttemplates.xml file
  1. 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
  2. Say you rename the file as – Customalerttemplates.xml
Note: If we edit the OOB alerttemplates.xml file, any further sharepoint updates/service pack may overwrite our changes

2.       Create custom alert template in Customalerttemplates.xml file
    1. Select appropriate template in the file and copy it
    2. Rename the new template with unique name – say WorkflowSuite_CustomTemplate
    3. Do required changes in the above template

3.       Update Customalerttemplates.xml file in contentdb
    1. 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.
    2. Reset IIS
    3. Restart sharepoint timerjob service.
      1. net stop SPTimerV4
      2. net start SPTimerV4

        Note: This step needs to be repeated after every single change we make in the Customalerttemplates.xml file.

         
4.       Set the new custom alert template to our list
    1. 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

Popular posts from this blog

How to Improve Workflow Performance in SharePoint Server 2010

PowerShell Script to Check and Generate Report on Access Rights for a Specific User:

Disable Loopbackcheck using PowerShell