ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

25-Emailing Application

 

In my previous tutorial, we learn how to send an email. This time, we will learn here how to create a Sending Mail application in Visual basic 2008 .

 

 

Here’s the example on how to create a Sending Mail application.

  1. Open the Visual Basic, select “File” on the menu, hit new and create a new project.
    01_helloworld
  2. The New Project dialog will appear.
    create2s
    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.
    24-send email
  4. Double click the button to fire the event handler of it and do this following code.
    1. Imports System.Net.Mail
    2. Public Class Form1Private Sub btnsend_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnsend.Click
    3. Try
    4. Dim SmtpServer As New SmtpClient
    5. Dim Semail As New MailMessage()
    6. SmtpServer.UseDefaultCredentials = False
    7. SmtpServer.Credentials = New Net.NetworkCredential("email@gmail.com", "password")
    8. SmtpServer.Port = 587
    9. SmtpServer.EnableSsl = True
    10. SmtpServer.Host = "smtp.gmail.com"Semail = New MailMessage()
    11. Semail.From = New MailAddress(txtFrom.Text)
    12. Semail.To.Add(txtTo.Text)
    13. Semail.Subject = "Sending Email"
    14. Semail.IsBodyHtml = False
    15. Semail.Body = txtMsg.Text
    16. SmtpServer.Send(Semail)
    17. MsgBox("Mail already sent.")Catch ex As Exception
    18. MsgBox(ex.Message)
    19. End Try
    20.  
    21. End Sub

Provide gmail address and real password for credentials.

Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

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