![]() | ![]() | ![]() |
Example 1 uses a FILENAME statement to send electronic mail. The report is included as an attachment file in the email message.
Example 2 uses the %STPBEGIN and %STPEND macros to send electronic mail. The output is included as an email attachment. The "MyPackage.spk" attachment file is a ZIP archive file, so you can open the file with a ZIP file utility of your choice. This SAS Stored Process uses STREAM Output.
For example:
.../Lev1/SASApp/StoredProcessServer/sasv9_usermods.cfg
For your.smtp_server.host, substitute the Simple Mail Transport Protocol (SMTP) server that supports email access for your site: For example:
-emailsys smtp -emailhost your.smtp_server.host
Usage Note 23636 "How can I dynamically e-mail output from ODS?"
Publishing a Package to E-Mail
Sending Electronic Mail Using the FILENAME Statement (EMAIL)
EXAMPLE 1
/* This stored process uses a FILENAME statement to send */
/* a report to the user as an email attachment. */
*ProcessBody;
%let dir = %sysfunc(pathname(WORK));
filename tempfile "&dir.\report.html";
ods html body=tempfile;
proc print data=sashelp.class;
run;
ods html close;
filename outbox email "Bill.Smith@wxyz.company.com"
subject="Your Stored Process Report"
replyto="some.user@wxyz.company.com"
attach="&dir.\report.html";
data _null_;
file outbox;
put "Your report is included in the attached file.";
run;
data _null_;
file _webout;
put '<HTML>';
put '<H1>Your request was completed</H1>';
put '<H1>An email message will be sent to you.</H1>';
put '</HTML>';
run;
EXAMPLE 2
/* This stored process uses the %STPBEGIN and %STPEND */
/* macros to create a package that is sent to the user */
/* as an email attachment. The attachment file is */
/* a ZIP archive file. */
/* Note: Run this stored process request using */
/* STREAM Output. */
*ProcessBody;
%let _RESULT=PACKAGE_TO_EMAIL;
%let _ARCHIVE_PATH=TEMPFILE;
%let _EMAIL_ADDRESS=Bill.Smith@wxyz.company.com;
%let _SUBJECT=Your Stored Process Report;
%let _ARCHIVE_NAME=MyPackage;
%STPBEGIN;
proc print data=sashelp.class;
run;
%STPEND;
/* Send a message back to the client user */
data _null_;
file _webout;
put "<h1>Your request completed execution</h1>";
run;
/* In SAS 9.2, you can use the _STATUS_MESSAGE reserved */
/* macro variable to return a message to the client user. */
/* For example: */
/* */
/* %let _STATUS_MESSAGE = <h1>Your request completed.</h1>; */
| Product Family | Product | System | SAS Release | |
| Reported | Fixed* | |||
| SAS System | SAS Integration Technologies | z/OS | 9.1 TS1M3 SP4 | |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 SP4 | |||
| Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 SP4 | |||
| Microsoft Windows 2000 Server | 9.1 TS1M3 SP4 | |||
| Microsoft Windows 2000 Professional | 9.1 TS1M3 SP4 | |||
| Microsoft Windows NT Workstation | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 SP4 | |||
| Microsoft Windows XP Professional | 9.1 TS1M3 SP4 | |||
| Windows Vista | 9.1 TS1M3 SP4 | |||
| 64-bit Enabled AIX | 9.1 TS1M3 SP4 | |||
| 64-bit Enabled HP-UX | 9.1 TS1M3 SP4 | |||
| 64-bit Enabled Solaris | 9.1 TS1M3 SP4 | |||
| HP-UX IPF | 9.1 TS1M3 SP4 | |||
| Linux | 9.1 TS1M3 SP4 | |||
| Linux on Itanium | 9.1 TS1M3 SP4 | |||
| OpenVMS Alpha | 9.1 TS1M3 SP4 | |||
| Solaris for x64 | 9.1 TS1M3 SP4 | |||
| Tru64 UNIX | 9.1 TS1M3 SP4 | |||
| Microsoft® Windows® for x64 | 9.2 TS2M0 | |||
| Linux for x64 | 9.2 TS2M0 | |||
| OpenVMS on HP Integrity | 9.2 TS2M0 | |||
| Type: | Usage Note |
| Priority: |
| Date Modified: | 2010-05-06 16:02:26 |
| Date Created: | 2010-03-31 11:48:09 |


