这是我的代码,它运行没有错误,但突然 出现异常 SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。
Dim smtpserver As New SmtpClient()
Dim mail As New MailMessage()
smtpserver.Credentials = New Net.NetworkCredential("myemail@gmail.com", "mypass")
smtpserver.Host = "smtp.gmail.com"
smtpserver.Port = "587"
mail = New MailMessage
mail.From = New MailAddress("myHouseHQ@gmail.com")
mail.To.Add(Form2.TextBox1.Text)
mail.Subject = "EagleEyes"
mail.Body = "EagleEyes has detected a movement!"
If emailphoto Then
Dim attach As New Attachment("D:\hi" & sm & ".jpg")
mail.Attachments.Add(attach)
End If
smtpserver.EnableSsl = True
smtpserver.UseDefaultCredentials = False
' Try1
smtpserver.Send(mail)
'Catch ex As SmtpException
'MsgBox("Error Connection!" & ex.Message)
'End Try
sm += 1
答案 0 :(得分:1)
不要使用""在港口。
请尝试使用此端口:
smtpserver.Port = 587