Access VBA send email with html body

Murray Brown
Murray Brown used Ask the Experts™
How do I modify the following VBA code so that I can send the body of the email
as html eg  

Dim oHBody As String = ""
            oHBody = oHBody & "<html><body><font size=3  color=" & sColor1 & " name = 'Calibri'>" & oIntro & "</font></body></html>"
            oHBody = oHBody & "<br>"

Sub SendReports(DisplayMsg As Boolean, Optional AttachmentPath)
    Dim objOutlook As Object
    Dim objOutlookMsg As Object
    ' Create the Outlook session.
    Set objOutlook = CreateObject("Outlook.Application")
    ' Create the message.
    Set objOutlookMsg = objOutlook.CreateItem(0)
    With objOutlookMsg
        '.To = strTo
        'Subject = strSubject
        '.Body = strBody
        '.Attachments.Add strAttach
    End With
    Set objOutlook = Nothing
End Sub

Open in new window

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ste5anSenior Developer
Please use the CODE button..

Use the BodFormat property to set the appropriate format and assign your body to the HTMLBody property.
John TsioumprisSoftware & Systems Engineer
Just create a simple email in Outlook (HTML)...switch to source and copy that to a String variable...
Take a look at this Article :
A tag of "Microsoft Access" is missing here
President / Owner CARDA Consultants Inc.
Distinguished Expert 2018
Instead of

.Body =  strBody

Open in new window

you use

.HTMLBody =  strBody

Open in new window

You may like to use a reusable function such as
NoahHardware Tester and Debugger
Hi there! :)

You need something like this in your With/EndWith statement instead.

.HTMLBody = "<p><font face=""Calibri"" size=""3"" color=""red""><b>Your Message Here</b></font></p>

Open in new window

Murray Developer


Thanks very much

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial