Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Imports System.Net
Imports System.Net.Mail

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        lblDateTime.Text = "Date: " & Date.Today() & " " & "Time: " & TimeOfDay()

    End Sub

    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
        Try
            Dim email As New MailMessage()
            Dim smtp As New SmtpClient()

            smtp.UseDefaultCredentials = False
            smtp.Credentials = New Net.NetworkCredential(txtUsername.Text, txtPassword.Text)
            smtp.Port = 465
            smtp.EnableSsl = True
            smtp.Host = "smtp.gmail.com"

            email = New MailMessage()
            email.From = New MailAddress(txtUsername.Text)
            email.To.Add(txtTo.Text)
            email.Subject = txtSubject.Text
            email.IsBodyHtml = False
            email.Body = richTxtBody.Text
            email.Priority = MailPriority.High

            smtp.Send(email)
            MsgBox("Message Sent Successfully.", MsgBoxStyle.Information)

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)

        End Try
    End Sub
End Class


Please help me with the error... I used the port for the gmail smtp server 587 but the application gave an exception "smtp server not responding". so i googled and discovered gmail new smtp port to be 465 which i used. Now if i click the send button, the application delays for some minute and finally gives the error "the operation has timed out" ... please what is the problem with the code, i mean what am i doing wrong. or do i have to configure my gmail account to allow me use it as a gateway for smtp? .
Posted
Updated 9-Feb-14 5:38am
v2

1 solution

You will not be able to send email using the Google email server.
I dont think it is possible - and if it is, I'm sure it will be charged.
 
Share this answer
 

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