Customers often ask if it’s possible to modify the content of e-mails SharePoint sends as alerts. Normally we answer that it’s not necessary to modify the content, because we see everything we need, including a hyperlink to the item itself.

Using the SharePoint SDK Microsoft has implemented an option to modify the e-mail. This article is a follow up to the knowledge base article 948321, which describes how to do these customizations.

What you need to know:

  1. You have to create an assembly an put it into the global assembly cache
  2. You have to create your own alerttemplates.xml to use your assembly
  3. You have to register your own alerttemplates.xml with STSADM for every site-collection, which should use the customized e-mails

The process itself is very easy. The problem is, what we can do with the e-mail. The example in the knowledge base creates a new body for the mail, but most customers just want to include some more information, and that’s the real problem. The OnNotification-method we have to implement in our assembly gets the body of the e-mail as SharePoint creates it with the default setting. This body is some kind of html, but it’s not a well formed xml. So it’s not easy to add information anywhere in the body. Putting the information at the top or at the bottom of the body is ease, because we can locate the <body> and the </body> tags in the body using string operations. But if we want to place any information at a random place in the body, we have to implement some crazy functions, because the content of the body depends on the structure of the list and on the modifications done by the user.

What I’ve actually not have seen is an option, to de-register my customized alerttemplates.xml. STSADM just knows the operation updatealerttemplates, so the only way I see is to run this command with the standard alerttemplates.xml.

Conclusion: the SharePoint SDK implements options to modify alert e-mails. To implement real modifications of the mail body is not so easy, because of the not well-formed html, Microsoft uses in the body of the mail. Implementing your own mail-body seems to be very easy.

Advertisements