25-Emailing Application

0
320

This tutorial is all about 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 TryEnd Sub

Provide gmail address and real password for credentials.

 

 

Readers might read also:

 

 

 

Facebook Comments
(Visited 33 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here