相关疑难解决方法(0)

使用Gmail发送电子邮件会导致超时错误

我们正在测试一些代码,以便从表单中使用Gmail发送电子邮件,但会收到超时错误.

您能否告诉我们此代码中缺少什么来发送电子邮件?

    Try
        Dim SmtpServer As New SmtpClient()
        Dim mail As New MailMessage()

        SmtpServer.EnableSsl = True
        SmtpServer.Credentials = New Net.NetworkCredential("ouremail@gmail.com", "MyPasswordGoesHere")
        SmtpServer.Port = 465
        SmtpServer.Host = "smtp.gmail.com"

        mail.From = New MailAddress("ouremail@gmail.com")
        mail.To.Add("ouremail@gmail.com")
        mail.Subject = "Test Mail"
        mail.Body = "This is for testing SMTP mail from GMAIL"

        SmtpServer.Send(mail)

        MsgBox("mail sent")

    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
Run Code Online (Sandbox Code Playgroud)

更新:使用MailBee进行代码更改.这就是我们向所有客户发送电子邮件的方式:

    Dim strSqlStatement As String = "Select CustomerName, Email " & _
                               "From Customers " & _
                              "Where Email Is Not Null"
    If IsConnected() …
Run Code Online (Sandbox Code Playgroud)

vb.net email smtp timeoutexception

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

email ×1

smtp ×1

timeoutexception ×1

vb.net ×1