11-13-2017 10:05 AM
I have the below code, which works fine to dynamically e-mail a distribution list I have dynamically each day.
How would I go about adding a new condition to factor in varying people to CC on the e-mail.
I have tried a few things however keep failing in my attempts. I tried adding select distinct EMAILCC into :EMAILCC1- from &DATA;
Then applying a CC section to the code, to="&&&EMAILCC&I", if anyone has any guidance it would be great
* send mail from DATA;
* get emails from DATA;
proc sql noprint;
select distinct EMAIL into :EMAIL1- from &DATA;
select count(distinct EMAIL) into :EMAILN from &DATA;
* cycle through emails;
%do I=1 %to &EMAILN;
filename temp email to="&&&EMAIL&I"
subject="OP Claims Daily Alert List";
ods html file=temp;
proc print data=&DATA noobs;
ods html close;
11-13-2017 10:26 AM
So you have a dataset with the email addresses in yes? Can you provide a sample as a datastep? Me I would go with:
data _null_; set email_addr end=last; by flag; if _n_=1 then call execute(cats('filename tmpmail to=("',mail,'")); else if first.flag and flag="bcc" then call execute(cats(') bcc=("',mail,'")); else call execute(cat(' "',mail,'")); if last then call execute('); data _null_; file tmpmail; put "Hello"; run;'); run;
This assumes a few things - as you have not supplied any information - in that you have a dataset called email_addr which looks like this:
The code goes through this dataset and generates the code need to email each of the people and the flag switches the addresses to bcc.
11-15-2017 03:21 AM
11-15-2017 05:51 AM
Well, the simplest way is to create an intermediary dataset like mine looks by:
data inter; set have (keep=col_a mail rename=(email=mail) in=a) have (keep=col_a mail rename=(emailcc=mail) in=b); flag=ifc(a,"to","bcc"); run;
Then use inter with my given code.