Click here to Skip to main content
12,249,797 members (49,059 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
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 18-Feb-13 23:17pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Try with
SmtpServer.Port = 587
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160426.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100