Sending Email SMTP Client Asynchronously
Posted on 2015-01-14
I need to send email asychronously without interrupting the calling thread, but the built in sendasync method does block the calling thread. If I run the software I'm using with an internet connection, there is no problem, but if I disconnect the computer from the internet, the software will freeze for approximately 15 seconds before giving up the attempt to send the email. Here is the code I'm using:
public void Send_Error_Email(SmtpClient inputClient, MailMessage inputMessage)
inputClient.SendCompleted += new SendCompletedEventHandler(error_SendCompleted);
if (inputMessage.To != null)
if (inputMessage.To.Count > 0)
//fix error regarding 'Mailbox unavailable'
Is there something wrong with this code? I thought it was supposed to run on its own thread based on the MSDN description, but it does not do so. Thanks for any help you can offer.