First published on TECHNET on May 29, 2012
Recently, I had a case where customer was creating SPAlert object using SharePoint object model code and things were not working out well.
What seem to happen was that whenever the condition that warrants alert trigger is met (e.g., an item is changed in a list), the alert email that was sent out was not the custom alert email template customer had setup but it was the out of the box email template.
The customer had created a custom alert template by following How to create a custom e-mail alert handler in Microsoft Office SharePoint Server article.
After investigation we found that the code they were originally using did not have SPAlert.AlertTemplate property assigned with the correct value. Once we provided the correct alert template to this property, the alert that was created through SharePoint object model code recognized the custom email template and used that template in the emails that were sent when the alert trigger condition is met.
Below is the sample code.
Line number 21 above was the statement missing in the original code. We need to specify the SPAlert.AlertTemplate property in order to get alert emails sent out using the custom email template.
Hope this helps!
Cross post from http://blogs.msdn.com/sridhara
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.