I am attempting to use the ATTACH statement in an email with multiple attachments and the following error is returned:
data _null_;
rd = strip(put(&run_date,mmddyyd10.));
call symputx('rd',rd);
run;
filename mymail email "xxx.sas@xxx.com";
data _null_;
file mymail
From = ("developers.sas@xxx.com")
To = (myself@xxx.com)
subject=(" Reports &rd");
attach=("\\xxx\Reports TOC &rd..xlsx" "\\xxx\REC.xlsx" );
run;
The log returns error 22 (syntax error saying it was expecting another operator and it fails. I also need to send several pdf files in the same email.
could you please try the below syntax of the code to send the attachments, this worked for me
filename outbox email
to='xxxx.xxxx@xxxxx.com'
type='text/html'
subject='subject line'
attach=('~path1/creat_bssa.csv' '~path2/creat_bssa.csv');
data _null_;
file outbox;
put 'Hi';
run;
could you please try the below syntax of the code to send the attachments, this worked for me
filename outbox email
to='xxxx.xxxx@xxxxx.com'
type='text/html'
subject='subject line'
attach=('~path1/creat_bssa.csv' '~path2/creat_bssa.csv');
data _null_;
file outbox;
put 'Hi';
run;
Now the code runs but no email appears.
Are you running this locally on your PC or on a remote SAS server? If it is on your PC then it is likely you need additional settings to get email working. If you are running this on a remote SAS server then talk to your SAS administrator about the correct settings for emailing from SAS.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.