Convert Word Document into mail

Posted on 2005-05-04
Last Modified: 2011-09-20

I have a program that generate a Word document via the Ole automation.
Now I need to write an e-mail with the same content as the Word document.

So, I want to generate a word document but once the document is generated convert it into mail containg Html.

How can I do,

Thank you

Question by:PHD
    1 Comment
    LVL 11

    Accepted Solution

    I guess you will need to make the next steps in order to achieve your goal:
    1. Save the word Document to HTML
    2. Place the resulting HTML inside the mail body (or as attachement)
    3. Send the mail

    == Step 1
    //Try this for saving the word document to HTML

    procedure TForm1.btnOpenAndSaveAsHTML(Sender: TObject);
    const wdFormatHTML = $00000008;
     WP : Variant;
     WP := CreateOleObject('word.application');
     WP.Visible := True;
     WP := UnAssigned;

    == Step 2
    // Try to load the HTML source in a memo and then this code will insert the HTML

    procedure TForm1.Button1Click(Sender: TObject);
      with NMSMTP1 do
        Host := 'smtp.x.y';
        Port := 25;
        UserID := 'MyID';
        EncodeType := uuMime;
        SubType := mtHtml;
        PostMessage.FromAddress := '';
        PostMessage.Body.Text := Memo1.Text;

    == Step 3 is obvious
    The SendMail...

    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.

    Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    759 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