I was trying to send bulk email asynchronously using the code below. The code works well, email was able to be sent but the "Sending email..." message was not displayed while sending and the btnCancel was not visible as well. Does anyone knows why??
Public Sub SendAsyncMail()
Dim mail As New MailMessage()
mail.From = New MailAddress("...")
mail.[To].Add(New MailAddress("..."))
mail.[To].Add(New MailAddress("..."))
mail.Subject = "Testing Email"
mail.Body = "..."
smtpClient.Credentials = New System.Net.NetworkCredential("...", "...")
smtpClient.Port = 587
smtpClient.Host = "smtp.gmail.com"
smtpClient.EnableSsl = True
Dim state As [Object] = mail
AddHandler smtpClient.SendCompleted, AddressOf smtpClient_SendCompleted
Try
smtpClient.SendAsync(mail, state)
lblMsg.Text = "Sending email..."
btnCancel.Visible = True
Catch ex As Exception
lblMsg.Text = ex.Message
End Try