How to open Outlook from Access in HTML format?

Hi Experts,

The following code opens an Outlook message in plain text format.
Sub SendEmail()
    Dim objOL  As Object
    Set objOL = CreateObject("Outlook.Application")
    
    Dim email  As Object
    Set email = objOL.CreateItem(0)    '0 = olItemEmail
    
    With email
        .To = "someone@somewhere.com"
        .Subject = "Test email"
        .Body = "This is a test email"
        .display  'use .Send to send the email immediately
    End With
End Sub

Open in new window

How can I have it opened in HTML format, the same way it opens when I start a new message using Outlook.

See attached.
Untitled.png
Untitled2.png
LVL 6
bfuchsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieAnalyst Assistant Commented:
When I run that code it opens an Outlook email in HTML format just like in your 2nd image.

What happens if you change the code to use HTMLBody instead of Body?
Sub SendEmail()
    Dim objOL  As Object
    Set objOL = CreateObject("Outlook.Application")
    
    Dim email  As Object
    Set email = objOL.CreateItem(0)    '0 = olItemEmail
    
    With email
        .To = "someone@somewhere.com"
        .Subject = "Test email"
        .HTMLBody = "This is a test email"
        .Display  'use .Send to send the email immediately
    End With
    
End Sub

Open in new window

0
bfuchsAuthor Commented:
Hi,

Tried that already
Also tried .BodyFormat = 2
none works.

Perhaps it has to do with the Office version, see following
https://www.experts-exchange.com/questions/29071079/Docmd-SendObject-stopped-to-work-after-installing-Outlook-2016.html?anchor=a42431252¬ificationFollowed=202485751#a42431252

Thanks,
Ben
0
bfuchsAuthor Commented:
Hi,

Actually was my mistake, I realized had used two methods to open outlook, one with docmd.sendobject and one as the above, so the send object was the plain text, while the code above indeed had it as HTML.

Thanks,
Ben
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bfuchsAuthor Commented:
Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.