Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between these two methods?

system.net.mail.smtpclient has two methods for which I am very confused.

1 . SendAsync(MailMessage, Object)

Sends the specified e-mail message to an SMTP server for delivery. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes. -MSDN

2 . SendMailAsync(MailMessage)

Sends the specified message to an SMTP server for delivery as an asynchronous operation. -MSDN

Notice that the names of two methods are different so it is not an overload. What exactly is the difference here?

I am looking for very clear answer as the description given by MSDN for both methods is very ambiguous (at least for me it is.)

like image 599
Bilal Fazlani Avatar asked Sep 04 '13 13:09

Bilal Fazlani


1 Answers

The difference is one SendMailAsync uses the new async/await technology and the other uses the old callback technology. And more importantly, the Object that's passed is simply passed into the event handler as the userState when the method completes.

like image 193
Mike Perrenoud Avatar answered Oct 05 '22 07:10

Mike Perrenoud