2015-02-23 52 views
0

我不断收到此错误消息 任何解决方案?VB.NET SMTP gmail不工作

“SMTP服务器要求安全连接或客户端没有经过认证5.5.1”

公用Sub SendCode()

GenerateCode() 

    Dim Mail As New MailMessage 
    Dim SMTPServer As New SmtpClient("smtp.gmail.com") 
    Try 
     SMTPServer.Credentials = New _ 
     Net.NetworkCredential("[email protected]", "password") 
     Mail.From = New MailAddress("[email protected]") 
     Mail.To.Add("[email protected]") 
     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 

回答