[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Send email via VB.net in HTML form?

Posted on 2008-10-12
6
Medium Priority
?
1,760 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 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
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.

 
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…
Suggested Courses

650 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