0

I am using the Following Code for my GMAIL Server SMTP Settings, but am unable to send emails.

Can anyone help me out...

        Dim emailClient As New SmtpClient("mail.gmail.com")
        Dim SMTPUserInfo As New System.Net.NetworkCredential("xxxxx@gmail.com", "abc123")

        emailClient.UseDefaultCredentials = False
        emailClient.Port = 465
        emailClient.EnableSsl = True
        emailClient.Credentials = SMTPUserInfo
        emailClient.Timeout = 1000000
        emailClient.Send(mail)

        emailClient = Nothing
        SMTPUserInfo = Nothing

     Catch ex As Exception
        MessageBox.Show(ex.Message & " Error Mails : ", Me.Text, MessageBoxButtons.OK)
    End Try
Asif Mansuri
  • 1
  • 1
  • 1
  • you are using a wrong port number for connecting to `gmail` change it as ` emailClient.Port = 587` –  Oct 14 '14 at 05:06
  • This has been answered before... http://stackoverflow.com/questions/22814590/sending-email-from-visual-basic/22853475#22853475 – Trevor Oct 14 '14 at 05:50

2 Answers2

0

I think, you should use following settings:

emailClient.Host = "smtp.gmail.com"
emailClient.port = 587
emailClient.EnableSsl = True
Harsh Vyas
  • 316
  • 4
  • 13
0

If you connect using SMTP, you can only send mail to Gmail or Google Apps users; if you connect using SSL/TLS, you can send mail to anyone. If your device or application supports SSL - connect to smtp.gmail.com on port 465. To connect with SSL, you need to provide a Google username and password for authentication.

Source: https://support.google.com/a/answer/176600?hl=en

Deepak Vasudevan
  • 360
  • 1
  • 3
  • 16