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);
private static void SendEmailCompletedCallback(object sender, AsyncCompletedEventArgs e)
// Get the unique identifier for this asynchronous operation.
//int token = int.Parse(e.UserState.ToString());
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.