?
Solved

Convert Word Document into mail

Posted on 2005-05-04
1
Medium Priority
?
180 Views
Last Modified: 2011-09-20
Hello,

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

0
Comment
Question by:PHD
1 Comment
 
LVL 11

Accepted Solution

by:
calinutz earned 2000 total points
ID: 13943274
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
uses
 ComObj;

procedure TForm1.btnOpenAndSaveAsHTML(Sender: TObject);
const wdFormatHTML = $00000008;
var
 WP : Variant;
begin
 WP := CreateOleObject('word.application');
 WP.Visible := True;
 WP.Documents.Open('C:\TEMP\MYDOC.DOC');
 WP.ActiveDocument.SaveAs
   'C:\TEMP\MYDOC.HTM',FileFormat:=wdFormatHTML);
 WP.ActiveDocument.Close;
 WP.Quit;
 WP := UnAssigned;
end;

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

procedure TForm1.Button1Click(Sender: TObject);
begin
  with NMSMTP1 do
  begin
    Host := 'smtp.x.y';
    Port := 25;
    UserID := 'MyID';
    Connect;
    EncodeType := uuMime;
    SubType := mtHtml;
    PostMessage.FromAddress := 'myAddress@blabla.com';
    PostMessage.ToAddress.Add('destination@yahoo.com');
    PostMessage.Body.Text := Memo1.Text;
    SendMail;
  end;
end;

== Step 3 is obvious
The SendMail...
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Suggested Courses
Course of the Month8 days, 15 hours left to enroll

621 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