Send Email using Google SMTP in vb.net

Here is small function which will allow you to send the emails
programatically using any SMTP server or you can also use the Google
SMTP server if you have a GMAIL account.

Function SendMail(ByVal strFrom As String, ByVal strTo As String, ByVal
strSubject As String, ByVal strBody As String) As Boolean
Dim mailmsg As New System.Net.Mail.MailMessage()

mailmsg.From = New MailAddress(strFrom)

mailmsg.To.Add(strTo)

mailmsg.Subject = strSubject

mailmsg.IsBodyHtml = True

mailmsg.Body = strBody

mailmsg.Priority = System.Net.Mail.MailPriority.Normal

Dim client As New System.Net.Mail.SmtpClient()

client.Host = “smtp.gmail.com”
client.Port = “587”

client.Credentials = New System.Net.NetworkCredential(“youremailid@gmail.com“, “Yourpassword“)

‘ client.EnableSsl = True

Dim userstate As Object = mailmsg

client.Send(mailmsg)
Return True
End Function

Replace the email id and the password with your own  gmail id and your gmail password