0

我正在尝试一次向多个人发送邮件。

我的代码是这样的;

 Dim SmtpServer As New SmtpClient()
            SmtpServer.Credentials = New Net.NetworkCredential("jasibs002@gmail.com", "solutions")
            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)
            SmtpServer.SendAsync(omail, Nothing)
        End While
        dr.Close()
        con.disconnect()

    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。

我想同时发送这封电子邮件,我该怎么做?

4

0 回答 0