一度に複数の人にメールを送信しようとしています。
私のコードは次のようなものです。
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("jasibs002@gmail.com", "someMadeUpPassword")
SmtpServer.Port = 25
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
Dim omail As New MailMessage()
omail.From = New MailAddress("jasibs002@gmail.com", "JaseemBinBacker", System.Text.Encoding.UTF8)
omail.Subject = "Test Mail"
Dim str As String
str = "Hai How Are You I am Sendig This Mail for Testing"
str = str + vbNewLine & "Checking"
str = str + vbNewLine & "Sucess"
omail.Body = str
Dim email As String
Dim cmdemail As New SqlCommand("SELECT Emailid FROM dbo.Email_tbl", con.connect)
dr = cmdemail.ExecuteReader
While dr.Read
email = dr("Emailid")
omail.To.Add(email)
End While
dr.Close()
con.disconnect()
SmtpServer.SendAsync(omail, Nothing)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
これを実行すると、次のエラーが発生します。
An asynchronous call is already in progress. It must be completed or canceled before you can call this method.
私の電子メールTable
には 10 を超える電子メール ID があります。