1

this is my code it was running without errors but suddenly an exception appears The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required.

Dim smtpserver As New SmtpClient()
    Dim mail As New MailMessage()
    smtpserver.Credentials = New Net.NetworkCredential("[email protected]", "mypass")
    smtpserver.Host = "smtp.gmail.com"
    smtpserver.Port = "587"
    mail = New MailMessage
    mail.From = New MailAddress("[email protected]")
    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
1
  • 1
    Have you tried reading the exception message? Your credentials are obviously incorrect
    – Kenneth
    Commented Dec 15, 2013 at 23:14

1 Answer 1

1

Don't use "" by the port.

Please try this for the port:

smtpserver.Port = 587

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.