Reputation: 1
Our company has a order page which has code in the code behind to send an email confirmation of an order using SmtpClient class. It works fine. The problem is that when there is a failure with our exchange server the email send event errors. We catch it and log it and notify the customer another way. It is usually caused by our backup server running which causes issues with email sends from time to time. How could we have the email try again every 30 minutes? I should note that all of our code is in our pages so we were thinking of creating a separate email class that would the page could call and process the request in the background and the page would be allowed to complete loading. Any advice would be appreciated.
Upvotes: 0
Views: 29
Reputation: 613
You could have a timer that starts each time the email fails to send, checking and trying to send the email every thirty minutes, if it is able to send, the timer stops. However, this could be taxing on your system if there are a lot of emails.
EDIT.
You could add the failed emails to a list or to a database. You could add a function to your code or make a new app that checks the time of the failed emails and last attempted sent time. If it is >= 30 minutes, attempt to send those emails again
Upvotes: 1