Search code examples
c#asp.netemailasynchronous

What is the difference between SendAsync and SendMailAsync methods of SmtpClient?


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


Solution

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