0

For parts of a site I'm developing - I want the OOTB SharePoint e-mail notification of a newly created alert (i.e. subscription) to be sent to the recipient as it should. But on occasions when I create the alert with different conditions I want to send my own custom e-mail.

For a bit more context, in summary, what I'm doing through code is creating one alert against a list for a user. That's fine. That's when I expect the OOTB e-mail.

But elsewhere in the site I expose the functionality to create several alerts at once against different lists - this is when I would like to send my own e-mail from code (to obviously avoid the user receiving an arbitrary amount of confirmation e-mails at once).

2 Answers 2

2

A really nice solution to this actually (one of the very few points in favour of SharePoint tbh) - the SPAlert.Update() has an overload that takes a bool to dictate whether the e-mail is sent or not.

1

I wrote up how to intercept communications here: Alert customization

If you go this route, you would just change the updates templates to use your custom code and write an override handler for the updates notifications.

===================================

But in this case, you may consider a simpler method to get the job done. Alerts are sent from the site. The site collection has a list of users that sign into it with the email address that alerts will be sent to If you use the profile service, then any changes you make at the site level will be overwritten from the data in the profile.

So, if you were to delete the email from the user in the sites user list then add your subscriptions, they would fail to send and then the email would be put back automatically. Then you would not be writing a bunch of code to process every email. Instead you could write a small powershell script to do it for you and likely be done by lunch.

1
  • Hi Ghangas. The latter is an interesting solution. It would be one that I would be willing to explore had it not been for the fact that the user may miss out on alert e-mails for subscriptions they already have. It somehow also doesn't seem feasible for me to make such modifications to a User's profile for this purpose. Thanks a lot anyway. +1. Jan 21, 2013 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.