Customize WSS Alert template

Customize WSS Alert template

There are two way to customize wss alert template
(1) Modify the template file
the default template file is 12\TEMPLATE\XML\alerttemplates.xml. it's a CAML file. You can rewrite it and use stsadm to deploy it
STSADM -o updatealerttemplates -url -filename
(2) Using a class inherit for interface IAlertNotifyHandler. Put the implement of this class into custom alert template file, and then you can use stsadm to deploy it

The advantage of the first method is can to need deal with alert logic(it is implemented by SharePoint), but the CAML is very complex, and you can't edit complex logic.
The second method is very agility, but some feature of the alert template will lost(such as the email which alerts modified item can display which words were changed, which words were newly added.)

This paragraph written by WSS SDK group will give you a a minute description about this topic

Instead of stsadm, you can also use code to deploy alert template, like this:

string templateName="customTemplate1";
// Get the template of the web server
SPAlertTemplateCollection ats = new SPAlertTemplateCollection((SPWebService)( base.GetCurrentSPSite().WebApplication.Parent));

//add or modify the template
SPAlertTemplate t = ats[templateName];

if( t == null )
t = ats.Add();

t.Name = templateName;
t.Xml = xmlDoc.InnerXml;


// Set the alert template for each list separately
SPList list = someList ;
list.AlertTemplate = ats[templateName];
list.ParentWeb.AllowUnsafeUpdates = true;