简体   繁体   English

VB.NET SMTP gmail不起作用

[英]VB.NET SMTP gmail not working

i keep getting this error message any solutions ? 我不断收到此错误消息任何解决方案?

"smtp server requires a secure connection or the client was not authenticated 5.5.1" “ smtp服务器需要安全连接,或者客户端未通过身份验证5.5.1”

Public Sub SendCode() 公共子SendCode()

    GenerateCode()

    Dim Mail As New MailMessage
    Dim SMTPServer As New SmtpClient("smtp.gmail.com")
    Try
        SMTPServer.Credentials = New  _
       Net.NetworkCredential("email@gmail.com", "password")
        Mail.From = New MailAddress("email@gmail.com")
        Mail.To.Add("email2@gmail.com")
        Mail.Subject = "Confirmation Code"
        Mail.Body = Me.Firstname & " " & Me.LastN & " This is a NO_REPLY confirmation Email, Confirmation Code:" & Me.ConfirmationCode & ""
        SMTPServer.Port = 587
        SMTPServer.EnableSsl = True
        SMTPServer.Send(Mail)
        MsgBox("mail sent")
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

You need to set port to 465 and SSL/TLS to auto... 您需要将端口设置为465,将SSL / TLS设置为自动...

I've used this code successfully... https://www.emailarchitect.net/easendmail/kb/vbnet.aspx?cat=2 我已成功使用此代码... https://www.emailarchitect.net/easendmail/kb/vbnet.aspx?cat=2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM