Consulting

Results 1 to 3 of 3

Thread: Paste HTML as body of mail

  1. #1
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location

    Paste HTML as body of mail

    Hi guys,

    In trolling around tonight, I found a really cool routine 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.

    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
    Last edited by Aussiebear; 04-16-2023 at 10:23 PM. Reason: Adjusted the code tags
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    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"
    K :-)

  3. #3
    Moderator VBAX Guru Ken Puls's Avatar
    Joined
    Aug 2004
    Location
    Nanaimo, BC, Canada
    Posts
    4,001
    Location
    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.
    Ken Puls, CMA - Microsoft MVP (Excel)
    I hate it when my computer does what I tell it to, and not what I want it to.

    Learn how to use our KB tags! -||- Ken's Excel Website -||- Ken's Excel Forums -||- My Blog -||- Excel Training Calendar

    This is a shameless plug for my new book "RibbonX - Customizing the Office 2007 Ribbon". Find out more about it here!

    Help keep VBAX clean! Use the 'Thread Tools' menu to mark your own threads solved!





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •