load word document to body message email without attachment

Osborne

Active Member
Are you asking if it is possible to have the contents of a Word document as the email body message? If so, then I think there are two possible options.

One option would be to convert the Word document to HTML and use the HTMLBody property as outlined here - http://progresscustomersupport-survey.force.com/OpenEdgeKB/articles/Article/000031657/p

Another would be to use MailEnvelope but for this I think you have Word to open the document first:
Code:
CREATE "Word.Application" oWord.
oDocument = oWord:Documents:Open("C:\EmailBody.doc").
olMail = oDocument:MailEnvelope:Item.
oDocument:Close(FALSE).
 

tha_ndut

New Member
Thanks for your advice.


I've tried it, but it still does not work.
body message in my email is still empty.


is there any other ideas?
 

Osborne

Active Member
Does this simple example work?:
Code:
DEFINE VARIABLE olMail AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE olWordApp AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE olWordDoc AS COM-HANDLE NO-UNDO.

CREATE "Word.Application" olWordApp.
olWordDoc = olWordApp:Documents:Open("C:\EmailBody.doc").

olMail = olWordDoc:MailEnvelope:Item.
olMail:To = "[EMAIL="myaddress@mycompany.com"]myaddress@mycompany.com[/EMAIL]".
olMail:Subject = "Subject here".
olMail:Save(). /* Email will be in the Drafts folder */

olWordDoc:Close(FALSE).

RELEASE OBJECT olWordDoc.
RELEASE OBJECT olWordApp.
RELEASE OBJECT olMail.
If not, then maybe your set-up does not work with MailEnvelope. The only other option would be to open the document in Word, copy the contents and paste into the email item:
Code:
DEFINE VARIABLE olOutlookApp AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE olMail AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE olInspector AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE olBody AS COM-HANDLE NO-UNDO.

CREATE "Outlook.Application" olOutlookApp.
olMail = olOutlookApp:CreateItem(0).
olMail:To = "[EMAIL="myaddress@mycompany.com"]myaddress@mycompany.com[/EMAIL]".
olMail:Subject = "Subject here".

/* The following four lines will paste the code copied in Word to the email body */
olInspector = olMail:GetInspector.
olInspector:Activate().
olBody = olInspector:WordEditor.
olBody:Range:Paste().

olMail:Display.

RELEASE OBJECT olMail.
RELEASE OBJECT olOutlookApp.
RELEASE OBJECT olInspector.
RELEASE OBJECT olBody.
 

tha_ndut

New Member
Thanks you for idea ..word document already loaded to body message and appear in the body message email,but only text which appear. We want image appear too in the message body.is there any idea?
 

Osborne

Active Member
That is odd, because with both examples I get exactly what appears in the Word document - text and images - all with the correct formatting. Have found it works perfectly under Windows XP, Vista and 7 and Office 2003, 2007 and 2010 and perfect results everytime - all are Professional versions.

Just do not know what to advise as it may be a Progress problem or an Office specific problem. If you write a macro in Word to create the email does that work? You could try looking/asking on these sites to see if others have experienced the same problem:

http://www.outlookcode.com/
http://msdn.microsoft.com/en-US/
 

Cringer

ProgressTalk.com Moderator
Staff member
I think it depends if the images are links in the word doc, or if they're embedded in the file itself. But I could be wrong.
 
Top