Fill in the selected result set into the message body in Outlook text

slayer

New Member
Does anyone have a sample code how can I fill in the selected result set by SQL or 4GL into the message body in Outlook?
 
slayer said:
Does anyone have a sample code how can I fill in the selected result set by SQL or 4GL into the message body in Outlook?

I've included a very straightforward solution below;

DEFINE VARIABLE myOlApp AS COM-HANDLE.
DEFINE VARIABLE Myitem AS COM-HANDLE.
DEFINE VARIABLE myRecipient AS COM-HANDLE.
DEFINE VARIABLE myAttachments AS COM-HANDLE.
CREATE "Outlook.Application" myOlApp.
ASSIGN Myitem = myOlApp:CreateItem(0).
Myitem:HTMLBody = "<html><body>".
/*ASSIGN recipients*/
ASSIGN myRecipient = Myitem:Recipients:Add("Recipient1").
myRecipient:Type = 1.
/*ASSIGN Cc recipients*/
ASSIGN myRecipient = Myitem:Recipients:Add("CCRecipient").
myRecipient:Type = 2.
/*ASSIGN Onderwerp*/
Myitem:Subject = "Subject".
/*ASSIGN mailtext*/
Myitem:HTMLBody = Myitem:HTMLBody + "This is the message body:".
/*ASSIGN attachments*/
ASSIGN myAttachments = Myitem:Attachments.
/*full attachment added */
myAttachments:Add ("C:\graph.pps", 1, , "Graph with results 4th quarter 1996").
/*Or hyperlink url to attachment*/
Myitem:HTMLBody = Myitem:HTMLBody + '<A HREF="http://test123.com/graph.pps">Graph with results 4th quarter 1996</A>'.
/*Show new mail*/
Myitem:HTMLBody = Myitem:HTMLBody + "</body></html>".
Myitem:Display.
myOlApp:Quit().
release object myOlApp.

Hope this helps....

Fred van der Meulen
Vitalogic BV
Netherlands..

 
Back
Top