Implementing Alert Handlers

Applies to: SharePoint Foundation 2010

You can catch notification events by implementing the OnNotification function in the IAlertNotifyHandler interface.

You can catch alert creation and modification events by implementing PreUpdate and PostUpdate functions in IAlertUpdateHandler.


Alert handlers are triggered only when the user has subscribed to e-mail alerts. They are not triggered when the user has chosen SMS alerts.

Implementing an Alert Handler

You can use the following procedure to implement an alert handler.

To implement an alert handler

  1. Create classes to implement the IAlertNotifyHandler and IAlertUpdateHandler interfaces

  2. Register the assemblies in the global assembly cache.

  3. Connect the alert template to the handler by using the Properties element of the alert template in the following format:

        Handler assembly strong name
        Fully qualified class name
        Other option properties you want to pass
        Class name
        Other properties

Alert templates are stored in AlertTemplates.xml and AlertTemplates_SMS.xml. These templates define the format, contents, and properties used to create alert messages from each list type. Developers can customize alerts by modifying a copy of one or both of these files and then loading the customized alert templates by using the command stsadm -o updatealerttemplates.


Do not modify AlertTemplates.xml or AlertTemplates_SMS.xml. These files may be overwritten when a service pack is installed. To make changes, make a copy of one or both files, edit the copy, and then make one or two calls of the stsadm -o updatealerttemplates command to override the original templates with your changes. Your changes are stored in the SharePoint Foundation configuration database. For details, see Alerts Overview and AlertTemplates Schema.


If you make a change to a given SPAlertTemplateType.* template outside of the Format element, you must make the same change to the corresponding SPSmsAlertTemplateType.* template.

Catching the Event

To catch the event when an alert is triggered, implement IAlertNotifyHandler. IAlertNotifyHandler.OnNotification is called when the alert is triggered. A SPAlertHandlerParams object is passed to the function. Then send the message with either an e-mail sending method such as SendEmail or an SMS message sending method, such as SendMessage(String).

To catch the event when a new alert is created or updated (so that you can change its properties or set new properties), implement the IAlertNotifyHandler interface. PreUpdate is called before the changes to the alert are committed to the database; PostUpdate is called after the changes are committed.


When implementing IAlertNotifyHandler, do not access SPAlertCollection or modify the SPAlert object, and always test whether an SPAlert property is null before accessing it.

See Also


Alerts in SharePoint Foundation