Private Sub cmdSendEmail_Click(sender As System.Object, e As System.EventArgs) Handles cmdSendEmail.Click Try Dim UserName As String = "mymailid@gmail.com" Dim mail As MailMessage = New MailMessage mail.From = New MailAddress(UserName) mail.To.Add(New MailAddress(EmailTo@gmail.com)) mail.Subject = "My Subject" mail.Body = "Message Body" mail.IsBodyHtml = True Dim client As SmtpClient = New SmtpClient("smtp.gmail.com", 587) client.EnableSsl = True client.Credentials = New System.Net.NetworkCredential(UserName, "myemailpassword") client.Send(mail) MessageBox.Show("Email Sent", "Title", MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)