You might want to save the email in a file, perhaps in an xml file, so that if the application crashes, you will not lose this information.
This file is downloaded when the application starts and it stores everything in memory, so when there are pending emails, it continues to be checked every 5 minutes or so, and then, as it sends each email, it will save the xml file so that if it works after sending 3 out of 10 emails, it will not resend these three when it starts.
But how you handle this will actually determine the specification of how to handle error conditions.
source share