The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. For more information, go to
Public Sub Send_Email_SMTP() Try Dim SmtpServer As New SmtpClient() SmtpServer.UseDefaultCredentials = False SmtpServer.EnableSsl = True Dim mail As New MailMessage() SmtpServer.Credentials = New _ Net.NetworkCredential("from@gmail.com", "password") SmtpServer.Port = 587 SmtpServer.Host = "smtp.gmail.com" mail = New MailMessage() mail.From = New MailAddress("from@gmail.com") mail.To.Add("to@gmail.com") mail.Subject = "My Email Subject" mail.Body = "My Email Body" SmtpServer.Send(mail) MsgBox("Email has been sent") Catch ex As SmtpException MessageBox.Show(ex.Message, "Send_Email_SMTP", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)