enter image description here当我从我的vb .net windows窗体发送电子邮件时,发生错误 我认为有一些身份验证问题.. MailBox不可用。服务器响应是:5.7.3 请求的行动中止; 用户未经过身份验证
答案 0 :(得分:0)
试试这段代码:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim Correo As New System.Net.Mail.MailMessage
Dim SMTP As New System.Net.Mail.SmtpClient
Correo.From = "VALID EMAIL FROM"
Correo.To.Add("VALID EMAIL TO)
Correo.Subject = "Subject text"
Correo.Priority = System.Net.Mail.MailPriority.Normal
Correo.IsBodyHtml = True
Correo.Body = "BODY OF EMAIL"
Correo.Attachments.Add("DIRECTORY FROM FILE TO ATTACH")
SMTP.Host = "VALID SMTP"
SMTP.Port = "VALID PORT"
SMTP.EnableSsl = "SSL TRUE OR FALSE"
SMTP.UseDefaultCredentials = False
SMTP.Credentials = New System.Net.NetworkCredential("user name", "password")
SMTP.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
Dim Token As Object = Correo
AddHandler SMTP.SendCompleted, AddressOf SmtpClient_OnCompleted
SMTP.SendAsync(Correo, Token)
' Wait response from SmtpClient_OnCompleted
End Sub
Public Sub SmtpClient_OnCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs)
End Sub