2017-06-28 80 views
0

所以我一直在嘗試使用谷歌的smtp服務器來建立一個聯繫表格,但我在標題中寫入錯誤。我試着在網上查找解決方案,並且我已經將密碼更改爲強密碼,我禁用了Gmail帳戶的安全性,我從服務器的Web瀏覽器登錄到Gmail帳戶。關於如何解決這個問題的任何想法?SMTP服務器需要一個安全的連接或客戶端未經過身份驗證(GMAIL)

Dim strFrom = "[email protected]" 
    Dim strTo = "[email protected]" 
    Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo)) 
    MailMsg.BodyEncoding = Encoding.Default 
    MailMsg.Subject = "This is a test" 
    MailMsg.Body = "This is a sample message using SMTP authentication" 
    MailMsg.Priority = MailPriority.High 
    MailMsg.IsBodyHtml = True 
    'Smtpclient to send the mail message 

    Dim SmtpMail As New SmtpClient 
    Dim basicAuthenticationInfo As New System.Net.NetworkCredential("[email protected]", "PASSWORD") 

    SmtpMail.Host = "smtp.gmail.com" 
    SmtpMail.Port = "587" 
    SmtpMail.UseDefaultCredentials = False 
    SmtpMail.Credentials = basicAuthenticationInfo 

    SmtpMail.Send(MailMsg) 
+0

[通過Gmail SMTP服務器用C#發送電子郵件]的可能的複製(https://stackoverflow.com/questions/704636/sending-電子郵件通過Gmail的smtp服務器與C - 銳) – mason

+0

可能重複的[通過Gmail在.NET中發送電子郵件](https://stackoverflow.com/questions/32260/sending-email-in-net-通過Gmail郵箱) – VDWWD

回答

0

你太親近了。

您需要添加以下設置,它的工作:

smtpMail.enabledssl = true 
相關問題