PDA

View Full Version : Paste HTML as body of mail



Ken Puls
02-06-2006, 11:27 PM
Hi guys,

In trolling around tonight, I found a really cool routine (http://www.devx.com/vb2themax/Tip/19111) to convert an ADO recordset into HTML format. This is awesome, as it will make my recordset look just the way I want, but now I'v got an issue.

How do I paste it into the body of a new mail item and actually have it apply it as HTML? All I've been able to accomplish is to send a text or HTML email showing my HTML. http://vbaexpress.com/forum/images/smilies/100.gif

Code for the email is as follows:

Set oMail = CreateItem(olMailItem)
With oMail
.To = "theemail@thedomain.com"
.Subject = "This should be HTML!"
.BodyFormat = olFormatHTML
.Body = sReportDtls
.Display
' .Send
End With

Killian
02-07-2006, 06:07 AM
Hi Ken,

That is quite a nifty find...

And you're just missing a small detail - when working with a mailitem with HTML BodyFormat, you need to use the "HTMLBody" property rather than "Body"

Ken Puls
02-07-2006, 09:28 AM
Cool, thanks Killian! I'll give that a shot, although I could have sworn I tried that...

I'll let you know when I get back to it later tonight. :)