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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.