EDN Admin
Well-known member
Hi,
I have some problems getting an email sender to work. With a normal smtp-server it works ok, but if the customer got a gmail account I am in trouble!.
The code I am using looks likeim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New System.Net.NetworkCredential(txtMail.Text, txtGmailPassword.Text)
SmtpServer.EnableSsl = True
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress("mail@xxx.no")
mail.To.Add(txtMail.Text)
mail.Subject = "xxxx - just a mail control"
mail.Body = "This is a test e-mail message do not respond"
SmtpServer.UseDefaultCredentials = False
SmtpServer.Send(mail)
The error I get is as follows:The SMTP-server demand a secure connection or the client was not approved. the Server response was: 5.5.1 Authentication Required. Learn more at
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at frmFirstScreen.SendSilentMail() i C:VB_Net ProgrammerfrmFirstScreen.vb:linje 281 - SendSilentMail
I have tried the various suggestions both here and elsewhere on the Net, but with no luck to now.
Could somebody please point out what I am doing wrong here - it should be straight forward - but ...
Kind regards
Jorgen
levesen
View the full article
I have some problems getting an email sender to work. With a normal smtp-server it works ok, but if the customer got a gmail account I am in trouble!.
The code I am using looks likeim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.Credentials = New System.Net.NetworkCredential(txtMail.Text, txtGmailPassword.Text)
SmtpServer.EnableSsl = True
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
mail = New MailMessage()
mail.From = New MailAddress("mail@xxx.no")
mail.To.Add(txtMail.Text)
mail.Subject = "xxxx - just a mail control"
mail.Body = "This is a test e-mail message do not respond"
SmtpServer.UseDefaultCredentials = False
SmtpServer.Send(mail)
The error I get is as follows:The SMTP-server demand a secure connection or the client was not approved. the Server response was: 5.5.1 Authentication Required. Learn more at
at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at frmFirstScreen.SendSilentMail() i C:VB_Net ProgrammerfrmFirstScreen.vb:linje 281 - SendSilentMail
I have tried the various suggestions both here and elsewhere on the Net, but with no luck to now.
Could somebody please point out what I am doing wrong here - it should be straight forward - but ...
Kind regards
Jorgen
levesen
View the full article