My company has recently switched to SAS Enterprise Guide and I am updating all my codes. One thing that I need to do is send out large batches of emails with attachments.
I know that to include .xlsx files you need to add the line
content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" lrecl=32000
to your attach= statement.
My question is, how do you send multiple attachments, of the same or different types, in one email? I have verified that each attachment works individually (I have six total attachments to send), but only the last one attached can be opened.
Thanks!
%macro emaildata (to_address, attachments);
Filename output email;
data _null_;
file output
to = (&to_address.)
subject = "subject"
attach = (&attachments. content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" lrecl=32000);
put "text.";
run;
%mend emaildata;
%emaildata (recipient, "&attachment1." "&attachment2." "&attachment3." "&attachment4." "&attachment5." "&attachment6.");
This works for me:
/* email files */
filename outbox email 'ron@acme.com';
data _null_;
file outbox
/* Overrides value in filename statement */
to=("&EMAILADDRESS" )
subject="reports "
attach=
(
"&outputpath./&pdbym._results.csv"
"&outputpath./&pdbym._detail.csv"
"&outputpath./177_&pdbmy.-&pdemy..html"
"&outputpath./177_&pdbmy.-&pdemy..pdf"
"&outputpath./177_&pdbmy.-&pdemy..xlsx" content_type="application/xlsx" lrecl=32000
"&outputpath./Claims_&pdbmy.-&pdemy..pdf"
"&outputpath./Claims_&pdbmy.-&pdemy..html"
"&outputpath./Claims_&pdbmy.-&pdemy..rtf"
"&outputpath./Lines_&pdbmy.-&pdemy..pdf"
"&outputpath./Lines_&pdbmy.-&pdemy..html"
"&outputpath./Lines_&pdbmy.-&pdemy..rtf"
"&outputpath./claims30.xlsx" content_type="application/xlsx" lrecl=32000
"&outputpath./interest.xlsx" content_type="application/xlsx" lrecl=32000
"&outputpath./badclaims1.xlsx" content_type="application/xlsx" lrecl=32000
"&outputpath./badclaims2.xlsx" content_type="application/xlsx" lrecl=32000
"&outputpath./Detail_File.xlsx" content_type="application/xlsx" lrecl=32000
)
;
put "Enjoy these exciting reports .";
run;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.