How to Send an HTML Email With VB

Save

HTML emails provide your users with an interactive message. These emails incorporate links and images, so users can view your products; this type of email is also frequently used for newsletters, follow-up communication and sales. Visual Basic (VB) is a part of the Microsoft .NET framework, which gives you the tools necessary to send HTML emails to your customers. Sending an HTML email is similar to sending a text email in VB, but it requires HTML input for the email body.

  • Create your email and HTML variables. The email variable calls the class library used to send email in VB. The HTML variable contains the email's body. In this example, the HTML email is a simple letter that contains bold text. The following code shows you how to create variables in VB:

    Dim email As New MailMessage()
    Dim theEmail As String

  • Assign a message body to the "theEmail" variable. The code value you use is converted to an HTML message. The message can contain images, tables, links and formatted text. The following code creates an HTML email string:

    theEmail = "<b>Buy Now</b> <a href='youremail@domain.com'>Click here</a> "

  • Set up the email message properties. Several properties are required to send the email. The email class requires the recipient and send email, message body and format properties. The following code sets up your email object:

    email.To = "your_recipient@domain.com"
    email.From = "your_email@domain.com"
    email.Subject = "This is an HTML email sample."
    email.BodyFormat = MailFormat.Html
    email.Body = theBody

  • Set up the server to relay the message. Each time you send email, an outgoing SMTP server is used. The SMTP value is found in your email client software settings, or it is provided by your Internet Service Provider (ISP). The following code sets up the outgoing email email server for VB:

    SmtpMail.SmtpServer = "smtp.outgoing_server.com" 'this value is replaced with the SMTP server provided by your ISP

  • Send the email. A simple "Send" command is used to send your recipient the email. The following code executes the HTML command and sends it to your recipient:

    SmtpMail.Send(email)

References

  • Photo Credit aqua email image by Ruslana Stovner from Fotolia.com
Promoted By Zergnet

Comments

You May Also Like

Related Searches

Check It Out

Geek Vs Geek: Robot battles, hoverboard drag race, and more

M
Is DIY in your DNA? Become part of our maker community.
Submit Your Work!