Click here to Skip to main content
15,891,657 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
i want to create a application that send email via gmail, but does not work.
I tried to see if I reached the server smtp.gmail.com on port 465 via telnet (telnet smtp.gmai.com 465) and this works.
Thanks in advance for your help

this is code:
Sub Main()
Dim SmtpServer As New SmtpClient()
SmtpServer.Port = 465
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
SmtpServer.UseDefaultCredentials = False
SmtpServer.Timeout = 8000
SmtpServer.Credentials = New Net.NetworkCredential("mail-from@gmail.com", "Password")

Dim m As New MailMessage
m.To.Add("mail-to@libero.it")
'm.From = New MailAddress("mail-from@gmail.com")
m.Body = "Test Message"
m.Subject = "Test Subject"
Try
SmtpServer.Send(m)
Catch ex As Exception
MsgBox(ex.ToString())
End Try

End Sub
Posted

1 solution

Try with
C#
SmtpServer.Port = 587
 
Share this answer
 
Comments
gianLuca1978 19-Feb-13 5:31am    
thanks for your reply, however i have tried with the port 587 but i received immediately the error, while if i use a port 465 i received error before the timeout. then i try a "telnet smtp.gmail.com 587" and the connection is refused.
Prasad_Kulkarni 19-Feb-13 5:34am    
You're welcome.

Please check this Similar thread[^], hope you get some help out.
gianLuca1978 19-Feb-13 5:55am    
thanks now I'll try to do some thinking on this post.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900