Solved

Send email via VB.net in HTML form?

Posted on 2008-10-12
6
1,745 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 13

Accepted Solution

by:
TechTiger007 earned 500 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
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

Industry Leaders: 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!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

717 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