Fix: BizTalk ESB exceptions notifications service resending emails

What is the ESB Exceptions notifications service?

The BizTalk ESB toolkit is an implementation of an enterprise service bus messaging standard. It allows for separation between message content, processes implementation, and process configuration.

As part of the ESB samples you find the ESB portal sample with some helper services. One of these services is the ESB exceptions notifications service. This is a windows service that checks every specified timespan for new exceptions happening on your platform and if there is anyone who created a subscription to this type of exception or not. If it finds valid subscriptions to the new exception it simply send emails to the subscribing user notifying them of the exceptions.


This service is actually very useful and would make your ESB support team more responsive and Performant.

The problem I found is that if someone actually added new subscriptions with a non-valid email address this would throw an exception while sending the email. And because this service is processing emails in batches it will consider the entire batch as not being sent although it might even have already sent messages within this batch already. This would make the service just keep sending the same messages over and over again until the request to send this email is removed from the database.


The solution is to change the behavior of the exceptions service by handling this condition. In my case all I needed in this case is to mark this email as being sent and just completely discard the error.

1-      Open the Alerts visual studio project from the folder “C:ProjectsESBSourceSourceSamplesManagement PortalESB.AlertService

2-      Open the file “Nofier.cs”

3-      Go to the function called Notify

4-      Change the send lines to be like the below




    System.Diagnostics.Trace.WriteLine("Email successfully sent");


catch (SmtpFailedRecipientsException )




alertEmail.Sent = true;

Please note that I left the marking of the email as being sent as I do not want it to reprocesses the same email again.

Leave a Reply