Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: 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 19-Feb-13 0:17am

1 solution

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

Solution 2

Try with
SmtpServer.Port = 587
  Permalink  
Comments
gianLuca1978 at 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 at 19-Feb-13 5:34am
   
You're welcome.
 
Please check this Similar thread[^], hope you get some help out.
gianLuca1978 at 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
0 Peter Leow 255
1 Mika Wendelius 240
2 CHill60 195
3 TheRealSteveJudge 180
4 Zoltán Zörgő 178
0 Sergey Alexandrovich Kryukov 8,658
1 OriginalGriff 6,591
2 Peter Leow 3,982
3 Zoltán Zörgő 3,604
4 Richard MacCutchan 2,510


Advertise | Privacy | Mobile
Web02 | 2.8.150123.1 | Last Updated 19 Feb 2013
Copyright © CodeProject, 1999-2015
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