postal icon indicating copy to clipboard operation
postal copied to clipboard

Async send email support

Open KiarashS opened this issue 10 years ago • 3 comments

Hi, postal support Async (.Net 4.5) ?

very thanks for postal!

KiarashS avatar Feb 21 '14 23:02 KiarashS

If it doesn't have async methods you could easily do

Task.Run(()=> {
email.Send();
}; 

Make sure to catch any exceptions in that

dotnetchris avatar Aug 22 '14 19:08 dotnetchris

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...

paulirwin avatar May 06 '15 16:05 paulirwin

I did just that. https://github.com/andrewdavey/postal/pull/116

paulirwin avatar May 06 '15 17:05 paulirwin