0

enter image description herewhen I send Email from my vb .net windows form than an error occur i think there is some authentication problem.. MailBox Unavailable.The Server Response Was:5.7.3 Requested Action Aborted; User Not Authenticated

simran
  • 1
  • 2

1 Answers1

0

Try this code:


   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

Shadros
  • 728
  • 2
  • 10
  • 19