We help IT Professionals succeed at work.
Get Started

smtp SendAsync always throws error "Failure sending email"

SweatCoder asked
Last Modified: 2012-05-11
I have an ASP.NET web page that calls a separate class library that attempts to send email async. When I send the email synchronously, it works perfectly:


but when I send async:

smtp.SendCompleted += new SendCompletedEventHandler(SendEmailCompletedCallback);
smtp.SendAsync(mail, GetUserIDFromCookie());

private static void SendEmailCompletedCallback(object sender, AsyncCompletedEventArgs e)
            // Get the unique identifier for this asynchronous operation.
            //int token = int.Parse(e.UserState.ToString());

            if (e.Cancelled)
                WriteLog("SendEmailCompletedCallback", "Async email cancelled.");
            if (e.Error != null)
                WriteLog("SendEmailCompletedCallback", "Async email error: " + e.Error.ToString());
                WriteLog("SendEmailCompletedCallback", "Async email sent!");

The callback method is never reached. Exception thrown during SendAsync(..).

Everything else is the same. Credentials the same for both methods. I have Async="true" in my @Page declaration on the calling aspx page.

I have googled on this for awhile and read several articles. I can't find anything I'm missing.
Watch Question
Top Expert 2011
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE