我必须遵循代码:
Try
Dim mail As New MailMessage()
Dim SmtpServer As New SmtpClient("smtp.gmail.com")
mail.From = New MailAddress(txtid.Text)
mail.[To].Add(TextBox1.Text)
mail.Subject = txtsub.Text
mail.Body = txtmess.Text
' mail.Attachments.Add(New Attachment(OpenFileDialog1.FileName))
SmtpServer.Port = 587
SmtpServer.Credentials = New System.Net.NetworkCredential(txtid.Text, txtpass.Text)
SmtpServer.EnableSsl = True
SmtpServer.Send(mail)
MsgBox("E-mail Has Been Send Successfully !")
Catch ex As Exception
MsgBox(ex.Message)
End Try
在台阶上
SmtpServer.Send(mail)
我总是收到错误消息:发送邮件失败
知道如何解决吗?
请注意,我使用的是 VB.NET