Hi,
I want to send emails to multiple recepients (with attachments) using the email addresses that are stored in the data set. Following is the code that I've used and the error message that I am getting.. please advise
---------------------CODE that I used - --------------------------------------------------
data TBL_EMAIL;
input
nuid $ 1-7
email_address $ 9-28
report_id $ 32-33
objectname $ 34-47
objecttype $ 49-64;
cards;
A111111 myemail@Domain.com 1 test report report
A111112 myemail@Domain.com 2 test report report
;
run;
%macro email(emailid);
FILENAME Mailbox EMAIL "&emailid"
Subject='Report - Ran okay'
ATTACH="M:\Monthly\Report.xlsx";
DATA _NULL_;
FILE Mailbox;
PUT "Hello";
PUT "Please find the Report as an attachment";
PUT "Thank you";
PUT " ";
RUN;
%mend email;
%macro email_error;
FILENAME Mailbox EMAIL 'xx@yy.com'
Subject='Report - Error' ;
DATA _NULL_;
FILE Mailbox;
PUT "Hello";
PUT "Please be advised that Report was generated with potential errors";
PUT "Thank you";
PUT " ";
RUN;
%mend email_error;
data Table2a_;
set Table2(where = (
report_id = 14
) );
if 180000 <= price <= 300000
then call execute ('data _null_; set TBL_EMAIL; where report_id=1; %email('||email_address||'); run;');
else call execute ('%email_error');
run;
----------------Error Message that I got ------------------------
NOTE: The file MAILBOX is:
E-Mail Access Device
ERROR: Invalid E-mail recipient.
-----------------------What worked ------------------------------
Following code worked (suggesting that there is something wrong in a way I am calling the email macro)
data Table2a_;
set Table2(where = (
location_ID = 14
) );
if 180000 <= price <= 300000
then call execute ('%email(myemail@Domain.com)');
else call execute ('%email_error');
run;
Thanks
Could you please share the log with the exact error message you are getting
also please try this , I am expecting that in the dataset you are passing you have the email_address variable with emailid's.
data Table2a_;
set Table2(where = (
location_ID = 14
) );
if 180000 <= price <= 300000
then call execute ('%email('||email_address||')');
else call execute ('%email_error');
run;
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 16. 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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: