Shared Sub sendMail(ByVal title As String, ByVal content As String)
Dim SmtpServer As New SmtpClient("smtp.gmail.com", 465)
SmtpServer.EnableSsl = True
SmtpServer.Credentials = New Net.NetworkCredential(username, password)
Dim mail As New MailMessage(username, username, title, content)
SmtpServer.Send(mail)
End Sub
I got the result of
System.Net.Mail.SmtpException: 'Failure sending mail.'
IOException: Unable to read data from the transport connection: net_io_connectionclosed.
What did I do wrong? Should I enable IMAP first at google?
My code is based on How do I send a gmail email in vb.net?
If I use port 587 instead of 465 I got
System.Net.Mail.SmtpException: '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'
Using port 25 yield
SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.200.109:25
Using 465 yield the original error