为什么GMail smtp配置会导致“发送邮件失败”错误?

时间:2015-12-29 20:06:01

标签: vb.net email smtp

这是我的代码。

    Dim SmtpServer As New Net.Mail.SmtpClient("smtp.gmail.com", 25)
    SmtpServer.Credentials = New Net.NetworkCredential("xxxxxx@gmail.com", "xxxxxxxxxx")
    Dim email As New Net.Mail.MailMessage("xxxxxx@gmail.com", _to, _subject, _message)
    email.Subject = _subject
    email.Body =
       "<html>" & _
       "<head>" & _
       "<meta http-equiv=""Content-Language"" content=""fr"">" & _
       "<meta http-equiv=""Content-Type"" content=""text/html; charset=windows-1252"">" & _
       "</head>" & _
       "<body>" & _
       _message & _
       "</body>" & _
       "</html>"
    SmtpServer.EnableSsl = True

    Try
        SmtpServer.Send(email)
        Return "OK"
    Catch ex As Exception
        Return ex.Message
    End Try

0 个答案:

没有答案