Close this search box.

Sending .NET EMail Via

I just finished wrapping up an article on how to send email from within a Windows or Web application with the System.Net.Mail namespace. One of the things I uncovered is that you can send email through the gmail smtp server. Of course you need to have a GMail account first…

Imports System.Net.Mail

'Start by creating a mail message object
Dim MyMailMessage As New MailMessage()

'From requires an instance of the MailAddress type
MyMailMessage.From = New MailAddress("")

'To is a collection of MailAddress types
MyMailMessage.To.Add("to_address_here@domain_name_hereyMailMessage.Subject = "GMail Test"
MyMailMessage.Body = "This is the test text for Gmail email"

'Create the SMTPClient object and specify the SMTP GMail server
Dim SMTPServer As New SmtpClient("")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("account, " account pwd")
SMTPServer.EnableSsl = True

Catch ex As SmtpException
End Try

Just thought I’d pass that little tidbit on.

Have a day. 😐

This article is part of the GWB Archives. Original Author: Jim Duffy

Related Posts