Usage Note 43716: How to use SAS® to email graphics output where the graph is embedded in the body of the email
Prior to the second maintenance release of SAS® 9.4 (TS1M2), it is not possible to send an email using SAS where graphics output is embedded in the body of the email. However, beginning with SAS 9.4 TS1M2, this is now possible. The following blog post documents how to do this beginning with SAS 9.4 TS1M2:
Use SAS to send an email that embeds a graph in the body of the email
However, prior to SAS 9.4 TS1M2, when emailing SAS/GRAPH® output, the graph output can be sent only as an attachment to the email and not embedded in the body of the email.
The sample code below demonstrates how to write a PNG graph file to disk and then to send the resulting graph as an attachment to an email:
ods _all_ close;
ods listing;
filename grafout 'c:\temp\sastest.png';
goptions reset=all device=png gsfname=grafout gsfmode=replace;
axis1 minor=none;
proc gchart data=sashelp.class;
where sex="F";
vbar age / sumvar=weight type=mean subgroup=age
nolegend discrete width=10 space=3
raxis=axis1;
run;
quit;
filename grafout clear;
filename sendmail email "first.last@company.com"
subject = "Test sending SAS/GRAPH output via email"
attach = "c:\temp\sastest.png";
data _null_;
file sendmail;
put "Here is the graph you requested";
run;
filename sendmail clear;
If you create multiple graphs that you want to send via email, the recommendation is to write these multiple graphs to a single RTF or PDF document. You can then send the RTF or PDF document as an attachment to your email.
Note that in order to send graphics output as an attachment to an email, you first need to set the EMAILSYS SAS system option to SMTP and the EMAILHOST SAS system option to the name of the SMTP email server for your site.
Operating System and Release Information
SAS System | N/A | z/OS | 9.1 TS1M3 SP4 | |
Microsoft® Windows® for x64 | 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 | |
Windows Vista for x64 | 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 | |
AIX | 9.1 TS1M3 SP4 | |
HP-UX | 9.1 TS1M3 SP4 | |
HP-UX IPF | 9.1 TS1M3 SP4 | |
Linux | 9.1 TS1M3 SP4 | |
Linux for x64 | 9.1 TS1M3 SP4 | |
Linux on Itanium | 9.1 TS1M3 SP4 | |
OpenVMS Alpha | 9.1 TS1M3 SP4 | |
Solaris | 9.1 TS1M3 SP4 | |
Solaris for x64 | 9.1 TS1M3 SP4 | |
Tru64 UNIX | 9.1 TS1M3 SP4 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
This note documents how to use SAS® to email graphics output where the graph is embedded in the body of the email.
Date Modified: | 2011-09-14 11:02:32 |
Date Created: | 2011-07-12 11:28:04 |