?
Solved

Send email via VB.net in HTML form?

Posted on 2008-10-12
6
Medium Priority
?
1,776 Views
Last Modified: 2012-05-05
Hi,

I have setup a form to send emails via Outlook and the emails are sent containing just text.

However, I want to send these emails containing HTML. Can anyone show me how I can set the below code to send the emails in HTML form?

Thanks,
Paul
Public Class Form1
 
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
 
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        OutApp = CreateObject("Outlook.Application")
        OutApp.Session.Logon()
        OutMail = OutApp.CreateItem(0)
 
        strbody = "<html><body><font color='red'>TEXT</font></b></body></html>" & _
                  "Dear all," & vbNewLine & vbNewLine & _
                  "This is a test email." & vbNewLine & _
                  "" & vbNewLine & _
                  "" & vbNewLine & _
                  "Thanks and regards," & _
                  "" & vbNewLine & _
                  "Paul"
    End Sub
 
    Private Sub SendClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SendClose.Click
        Dim DestinationEmail As String
        Dim RequestNumber As String
 
        RequestNumber = RequestNo.Text
        DestinationEmail = SendTo.Text
 
        With OutMail
            .To = DestinationEmail
            .CC = ""
            .BCC = ""
            .Subject = "DWP Service Desk - 4 DAY CLOSE - <" & RequestNumber & "> - chkd"
            .Body = strbody
            .send()
 
            MessageBox.Show("Email Sent!")
 
            'Clear Text Boxes
            SendTo.Text = ""
            RequestNo.Text = ""
            LocationCode.Text = ""
            Subject.Text = ""
        End With
 
 
    End Sub
End Class

Open in new window

0
Comment
Question by:m0tSiE
6 Comments
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 2000 total points
ID: 22697429
Try this

With OutMail
            .To = DestinationEmail
            .CC = ""
            .BCC = ""
            .Subject = "DWP Service Desk - 4 DAY CLOSE - <" & RequestNumber & "> - chkd"
            .Body = strbody
            .htmlbody = strbody
            .send()With OutMail
            .To = DestinationEmail
            .CC = ""
            .BCC = ""
            .Subject = "DWP Service Desk - 4 DAY CLOSE - <" & RequestNumber & "> - chkd"
            .htmlbody = strbody
            .send()
0
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22697456
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 22697466
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 19

Expert Comment

by:elimesika
ID: 22697555
0
 

Author Closing Comment

by:m0tSiE
ID: 31505440
Thanks, worked great! :D
0
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22697896
You are welcome
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month17 days, 12 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question