Link to home
Start Free TrialLog in
Avatar of Bill543
Bill543

asked on

Can I send an HTML file as body text using Outlook.MailItem?

I'm trying to send an HTML file as 'body text' via MS Access vba using the Outlook.MailItem feature.
I'm able to do it fine with the CDO message object as follows:
objMessage.CreateMHTMLBody "file://c|/temp/test.htm"

But when I try to do this with the Outlook message object, I get an error.
I couldn't find a 'CreateMHTMLBody' option using Outlook objects, so I tried:
objMailMessage.HTMLBody "file://c|/temp/test.htm"
But received an error :(

The reason why I'm trying to use Outlook objects instead of CDO is that I want to save to my Outlook drafts folder.

Avatar of omgang
omgang
Flag of United States of America image

I think you need to create a message template in Outlook using the html page.  Then you can create a new message using that template.  I have some code around here somewhere that does exactly that.  I'll see if I can dig it up.
OM Gang
ASKER CERTIFIED SOLUTION
Avatar of omgang
omgang
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bill543
Bill543

ASKER

Thanks! As usual you pulled through. Your solution worked for me.
I needed to add/edit the below line from your code:
'select message template for this region
Set olOutlookMsg = olOutlook.CreateItemFromTemplate _
("i:\outlook\templates\" & Reg & "_Broadcast.oft")