Chapter Contents |
Previous |
Next |
SAS Companion for the OS/2 Environment |
To send e-mail from within SAS, select the File pull-down menu and then select Send.... Your e-mail software provides the interface to send mail.
Note: You need an e-mail program that supports VIM before
you can take advantage of SAS e-mail support. Also, although you can use
the SAS System to send messages, you must use your e-mail program to view
or read messages.
Initializing E-Mail |
Note: The directory that contains the e-mail DLL file (for
example, VIM32.DLL) must be specified in your OS/2 PATH environment variable.
The SAS System uses the first e-mail DLL that it finds for the interface that
you specify. Your installed e-mail support must use 32-bit architecture.
For example, if your login ID is
J.B. Smith
and
your password is
rosebud
, your SAS invocation might look like this:
c:\sas\sas.exe -emailsys vim -emailid "J.B. Smith" -emailpw rosebud
Note: If you don't specify the EMAILID and EMAILPW system
options at invocation (and you are not otherwise signed on to your e-mail
system already), the SAS System will prompt you for them when you initiate
e-mail.
You must have a 32-bit e-mail client program to initiate e-mail from the SAS System.
Using the Send Mail Dialog Box to Send E-Mail |
You can access the Send Mail dialog box by selecting the Send... item from the File menu. Send Mail Dialog Box shows the Send Mail dialog box.
The following are descriptions of the fields in the Send Mail dialog box:
Some e-mail systems limit the note length to 32K (or 32,768 characters). Text that you enter in the Note: area will automatically wrap at the right side.
For large amounts of text, attach a text file as described below.
Use the [Attach File...] button to open a file selection dialog box that you can use to select files to attach. To remove an attachment, select the file's icon in the Attachments field and click on [Remove].
Note: The attached files are sent as
they exist on the
disk; that is, if you edit a file before attaching it to an e-mail message,
the saved version of the file is sent with the message.
To verify that the addresses that you specified in the To: and Cc: fields are valid, click on [Check Names]. If one or more of the addresses is ambiguous (that is, the mail program cannot locate them in the address books) the SAS System displays an error message and highlights the first ambiguous address.
Note that an ambiguous address is not necessarily invalid. It is possible to send mail to recipients outside your immediate local-area network (LAN) using gateways, whose addresses might not be resolved by using [Check Names].
Whether an address is considered invalid or ambiguous
depends on the e-mail program that you are using and on the configuration
of your network. For example, suppose that you want to send e-mail to a colleague
on the Internet. Your LAN might have a gateway to the Internet so that you
can address the mail to
JBrown@rhythm.com at Internet
(where
at
is the gateway
directive keyword and
Internet
is the name of a gateway on your LAN). Because
your e-mail program uses the
at
keyword to direct your message to the
Internet
gateway,
the address is considered valid. However, when you click on [Check
Names], the address is considered ambiguous because the final destination
address cannot be resolved by using the local address book. You can still
click on [Send] to send the message without an error.
Clicking on [Address...] invokes the address book facility for your e-mail program, provided that the facility is accessible.
Using the DATA Step or SCL to Send E-Mail |
In general, DATA step or SCL code that sends e-mail has the following components:
To send e-mail by using the DATA step or SCL, you must
be signed on to your e-mail program. For more information about how to use
your e-mail program with the SAS System, see Sending E-Mail from within the SAS System.
FILENAME fileref EMAIL 'address' <email-options>; |
Note: Each e-mail option can be specified only in a FILENAME statement
that overrides the corresponding SAS system option.
to="John Smith"
and
to=("J. Callahan" "P. Sledge")
are valid TO values.cc="John Smith"
and
cc=("J. Callahan" "P.Sledge")
are valid CC values.subject=Sales
and
subject="June Report"
are valid subjects.attach=opinion.txt
and
attach=("june94.txt" "july94.txt")
are valid file attachments.You can also specify email-options in the FILE statement inside the DATA step. Options that you specify in the FILE statement override any corresponding options that you specified in the FILENAME statement.
After using the FILE statement to define your e-mail fileref as the output destination, use PUT statements in your DATA step to define the body of the message.
Here are the directives that perform actions:
Suppose you want to share a copy of your SAS configuration file with your
coworker Jim, whose user ID is
JBrown
. Sending a File with the Data Step shows how to send the file with the DATA
step.
Sending a File with the Data Step
filename mymail email "JBrown" subject="My SASV8.CFG file" attach="c:\sas\sasV8.cfg"; data _null_; file mymail; put 'Jim,'; put 'This is my SAS configuration file.'; put 'I think you might like the'; put 'new options I added.'; run;
Attaching a File and Specifying Options in the FILE Statement sends a message and attaches a file to multiple recipients, and specifies the e-mail options in the FILE statement instead of the FILENAME statement:
Attaching a File and Specifying Options in the FILE Statement
filename outbox email "Ron B"; data _null_; file outbox /* Overrides value in */ /* filename statement */ to=("Ron B" "Lisa D") cc=("Margaret Z" "Lenny P") subject="My SAS output" attach="c:\sas\results.out" ; put 'Folks,'; put 'Attached is my output from the SAS'; put 'program I ran last night.'; put 'It worked great!'; run;
You can use conditional logic in the DATA step to send multiple messages and control which recipients get which message. For example, suppose that you want to send customized reports to members of two different departments. Sending Customized Messages Using the Data Step shows such a DATA step.
Sending Customized Messages Using the Data StepThe resulting e-mail message, and its attachments, are dependent on the department to which the recipient belongs.
filename reports email "Jim"; data _null_; file reports; length name dept $ 21; input name dept; /* Assign the TO attribute */ put '!EM_TO!' name; /* Assign the SUBJECT attribute */ put '!EM_SUBJECT! Report for ' dept; put name ','; put 'Here is the latest report for ' dept '.' if dept='marketing' then put '!EM_ATTACH! c:\mktrept.txt'; else /* ATTACH the appropriate report */ put '!EM_ATTACH! c:\devrept.txt'; /* Send the message. */ put '!EM_SEND!'; /* Clear the message attributes.*/ put '!EM_NEWMSG!'; /* Abort the message before the */ /* RUN statement causes it to */ /* be sent again. */ put '!EM_ABORT!'; cards; Susan marketing Jim marketing Rita development Herb development ; run;
Note: You must use the !EM_NEWMSG! directive to clear
the message attributes between recipients. The !EM_ABORT! directive prevents
the message from being automatically sent at the end of the DATA step.
Overriding SAS System Options shows how to send a message and to attach a file to multiple recipients, and it specifies the e-mail options in the FILENAME statement instead of the FILE statement. Specifying these options overrides the SAS system options EMAILID=, EMAILPW=, and EMAILSYS=.
Overriding SAS System Options.
filename outbox email "Ron B" emailsys=VIM emailpw="mypassword" emailid="myuserid"; data _null_; file outbox /* Overrides value in */ /* filename statement */ to=("Ron B" "Lisa D") cc=("Margaret Z" "Lenny P") subject="My SAS output" attach="c:\sas\results.out" ; put 'Folks,'; put 'Attached is my output from the SAS'; put 'program I ran last night.'; put 'It worked great!'; run;
The following example is the SCL code that is behind a FRAME entry that is designed for e-mail. The FRAME entry might look similar to the one shown in An Example E-Mail FRAME Entry.
The FRAME entry has objects that let the user enter the following information:
MAILTO | the user ID to send mail to. |
COPYTO | the user ID to copy (CC) the mail to. |
ATTACH | the name of a file to attach. |
SUBJECT | the subject of the mail. |
LINE1 | the text of the message. |
Invoking SCL Code from a FRAME Entry
shows the FRAME entry. This entry contains a pushbutton called SEND that invokes
this SCL code (marked by the
send:
label).
Invoking SCL Code from a FRAME Entry
send: /* set up a fileref */ rc = filename('mailit','userid','email'); /* if the fileref was successfully set up, open the file to write to */ if rc = 0 then do; fid = fopen('mailit','o'); if fid > 0 then do; /* fput statements are used to implement writing the mail and the components such as subject, who to mail to, etc. */ fputrc1= fput(fid,line1); rc = fwrite(fid); fputrc2= fput(fid,'!EM_TO! '||mailto); rc = fwrite(fid); fputrc3= fput(fid,'!EM_CC! '||copyto); rc = fwrite(fid); fputrc4= fput(fid,'!EM_ATTACH! '||attach); rc = fwrite(fid); fputrc5= fput(fid,'!EM_SUBJECT! '||subject); rc = fwrite(fid); closerc= fclose(fid); end; end; return; cancel: call execcmd('end'); return;
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.