How to implement HTMLBody in Outlook OlMailItem

Posted on 2008-11-19
Last Modified: 2013-11-10
I am usng a VB script to create an Outlook email taking the message body from an open Word Document..

the current code is..

    Set oItem = oOutlookApp.CreateItem(olMailItem)
    With oItem
        .Subject = mysubject
        .Body = Source.Sections(j).Range.Text..

I want to use HTMLBody instead.. how do I get Source.Sections(j).Range.Text to appear in say a <p>
Question by:chrisfixit
    LVL 76

    Accepted Solution

    Hi, chrisfixit.

    This should do it.

        .HTMLBody = "<p>" & Source.Sections(j).Range.Text & "</p>"

    Also, be sure to set the body format to HTML.  

        .BodyFormat = olFormatHTML
    LVL 1

    Author Closing Comment

    Thanks but in the end I saved the Doc as HTML then used the text File as soucre for HTMLBody.
    LVL 76

    Expert Comment

    by:David Lee
    You're welcome.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now