We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

24-Sending an Email

In Visual Basic, sending e-mails are allowed in your application. The System.Net.Mail is the namespace that contains classes  that is used for sending e-mails to a Simple Mail Transfer Protocol (SMTP) server for delivery.


The SmtpClient class allows applications to send e-mail by using the Simple Mail Transfer Protocol (SMTP).


Take note that in sending e-mail you must specify the SMTP host server because the Host and Port properties will be different for various host server.


In here, we will be using gmail server.

If the STMP server requires you for the authentication, you must need to give the Credentials


Sender’s email address should be provided same as the recipients using the MailMessage.From and MailMessage.To properties. Specify  also the content of message by using MailMessage.Body property.



  1. Open the Visual Basic, select “File” on the menu, hit new and create a new project.
  2. The New Project dialog will appear.
    Select “windows” in the project types, hit the “windows form application” in the templates and hit “ok“.
  3. Design the form this way. See it Below.
  4. Add the following code in the code editor.
    1. Imports System.Net.Mail
    2. Public Class Form1
    3. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    4. Dim E_Mail As New MailMessage
    5. E_Mail.Subject = "Emailling"
    6. E_Mail.To.Add("")
    7. E_Mail.From = New MailAddress("")
    8. E_Mail.Body = "This is an email from VB.NET"Dim smtp As New SmtpClient("")
    9. smtp.EnableSsl = True
    10. smtp.Credentials = New System.Net.NetworkCredential("username", "password")
    11. smtp.Port = "587"
    12. smtp.Send(E_Mail)
    13. End Sub
    14. End Class
Facebook Comments
(Visited 7 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: