postal
postal copied to clipboard
Async send email support
Hi, postal support Async (.Net 4.5) ?
very thanks for postal!
If it doesn't have async methods you could easily do
Task.Run(()=> {
email.Send();
};
Make sure to catch any exceptions in that
Task.Run in this case should be avoided because the .Send() method is IO-bound rather than CPU-bound. Task.Run should only be used for CPU-bound tasks. For IO-bound code, you should go async all the way up the call stack. There is a .SendAsync() method which returns Task and can be awaited, although the implementation of it could be a bit simpler if compiled for .NET 4.5 (or 4.0 with the BCL Async library) with async/await. I might submit a PR for that...
I did just that. https://github.com/andrewdavey/postal/pull/116