Hello all,
My client wants emails sent with one report in the body of the email and attached Excel files. The files, because they are large, are just straight.
proc export data=details outfile="&details" dbms=xlsx replace; sheet="Details Part1";
The report they want embedded in the same report is a straight result from another dataset.
I can figure out how to attach or print within the email but not both. Any examples you can point me to?
Thank you
This article is a good reference: How to send email using SAS
You will combine two of the techniques: add an attachment and include ODS output in the body of the email. Here's a simple example:
options emailsys=smtp
emailhost='yourmail.host.com';
%let outfile=c:\Projects\class.xlsx;
proc export
data=sashelp.class
file="&outfile"
dbms=xlsx
replace;
sheet="Class Roster";
run;
%let toList="recipient@destination.com";
FILENAME OUTPUT EMAIL
SUBJECT = "Impressive Report"
FROM = "Chris <chris.blogger@sas.com>"
TO = (&toList)
CT ='text/html'
attach=("&outfile."
content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
ods tagsets.msoffice2k(id=email)
file=OUTPUT(title="My report")
style=htmlencore;
/* The report body in the email */
title "Class Roster";
proc print data=sashelp.class;
run;
ods tagsets.msoffice2k(id=email) close;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.