Share this with your friends 

Sending Emails in VB.NET

0 ratings Views 584 
Author: Daniel_7464bf92 (Daniel Odongo)  View Profile |  View other solutions by this author

Question / Problem

Allow the computer to send emails using VB.NET without need for a mail server.


1. Create a demo form

2. Insert four text boxes (To, From, Subject and Body)

3. Insert a button in the form and call it ButtonSend

4. Import a package, system.net.mail. Inside ButtonSend, add the following code
Dim mail As MailMessage = New MailMessage()
mail.From = New MailAddress("'+me.fromtext.text+'")
mail.Subject = "'+me.subjtext.text+'"
mail.Body = "'+me.bodytext.text+'"
mail.IsBodyHtml = True
Dim smtp As SmtpClient = New SmtpClient()
smtp.Host = "smtp.gmail.com" 'Public smtp client
smtp.Credentials = New System.Net.NetworkCredential("type_your_email_address", "type_password")
smtp.EnableSsl = True

Applies to

VB 2005

Rank It

Login to rank it