Kbase 18886: How To Generate Email From A WebSpeed Application
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  2/26/2010 |
|
Status: Verified
GOAL:
How to generate e-mail from a WebSpeed application
GOAL:
How to send an e-mail from a Progress WebSpeed application
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge Category: Language (4GL/ABL)
FIX:
A common expectation of Web applications is e-mail confirmation of entered information. This Solution is intended as a guide for how to generate e-mail from a WebSpeed application. It is not intended as a complete reference, but lists some possible solutions.
There is nothing written directly into WebSpeed to facilitate emailing. However, using a variety of techniques, it is possible to send e-mail from within WebSpeed. The method you use is dependent on the version of WebSpeed you are using, and the platform you have deployed on.
WebSpeed on UNIX --
For WebSpeed UNIX, the easiest solution is to use the operating
system mail commands. Typically, sendmail and mailx would be used.
Use the OS-COMMAND or UNIX keywords to run the appropriate command.
For example:
Create a text file with the following format:
From: <from_address>
To: <to_address>
Subject: <subject>
<blank line>
<message contents>
Within the WebSpeed application, try the following command with
OS-COMMAND or UNIX:
/usr/lib/sendmail -oem -oi -f <from_address> <to_address> < filename
You will need to check your system documentation for the mail command you choose. This method will work for WebSpeed 2.X and WebSpeed 3.0X on UNIX.
WebSpeed on Windows NT --
For WebSpeed on Windows NT, the solutions differ because there are many varied ways of sending e-mail on Windows NT. One thing to remember is that WebSpeed 2.1 is based on Progress 8.1. This means it cannot use any ActiveX Automation to send e-mail. WebSpeed 3.0X can use ActiveX Automation.
For WebSpeed 2.1 on NT, there are various Microsoft and third-party command-line utilities that can be used to send e-mail. These can be accessed from WebSpeed the same way as UNIX, that is, using OS-COMMAND or DOS.
For example:
The postmail command is a command line utility distributed as part of a Windows NT Resource Kit. WebSpeed, issue the following with OS-COMMAND or DOS:
postmail -S"<subject>" -f"<from_address>" -H<mailhost> <to_address> < <message_file>
For WebSpeed 3.0X on NT, you can use ActiveX Automation for e-mail. For example, using MS Outlook:
DEF VAR objOutlook AS COM-HANDLE NO-UNDO.
DEF VAR objOutlookMsg AS COM-HANDLE NO-UNDO.
DEF VAR objOutlookRecip AS COM-HANDLE NO-UNDO.
CREATE "Outlook.Application" objOutlook.
objoutlookMsg = objOutlook:CreateItem(0).
objOutlookRecip = objOutlookMsg:Recipients:Add("<to_address>").
objOutlookRecip:Type = 1.
objOutlookMsg:Subject = "<subject>".
objOutlookMsg:Body = "<message_contents>".
objOutlookRecip:Resolve.
objOutlookMsg:Send.
objoutlook:Quit().
RELEASE OBJECT objOutlook.
RELEASE OBJECT objOutlookMsg.
RELEASE OBJECT objOutlookRecip.
Be aware that to use the code above successfully is required to start the WebSpeed broker using a user different from System account user.
See Progress Solution 19244, How To Start A Broker Using Domain\Account for more information.
Progress supplies two examples of emailing within WebSpeed 3.0, which do not tie the application into a particular e-mail client. These can be found in $DLC/src/samples/activex, under sendmail and usemapi. These examples will have to be modified for usage with WebSpeed, but the method used is still valid.