We have several instances where emails fail and stay in the queue. The problem is the email is never sent again automatically, you have to manually click resend. I've also noticed if one fails, it causes a backlog and doesn't let others send because that particular one failed.
So I thought a good way to automate this would be to create a scheduled task that runs every 3-5 hours and simply resends the failed emails. The code was very simple although the process isn't working as expected. Here is my scheduled task method
protected void ResendFailedEmails(ref string result)
{
try
{
EmailHelper.Queue.SendAllFailed();
result = "Completed successfully.";
}
catch (Exception ex)
{
result = ex.Message;
}
}
Am I missing something? Is there another method that works better? Is there a way to get the details or code as to why an email is failing?