BookmarkSubscribeRSS Feed
Sastech
Fluorite | Level 6

Hi, 

 

I wish to send email to multiple people from the dataset.

Dataset contains Name and email address. I should send each of them with Hi Name, with message body. 

In actual data around 100 email is present and sample data sharing below 

I have tried below method but getting an error 

 

data Employee;
  input Name $ Email :$30.;
datalines;
John John@xyz.com
david david@xyz.com
Joe joe@xyz.com
;
%macro sendreports(name,email);
filename outbox email;
data _null_;
file outbox
to= ("&email")
subject="Test subject"

file outbox;
put "Dear &name.,";
put "Thank you";
run;
%mend Sendreports;

data _null_;
Set Employee;
call execute(cats('%sendreports(',email,',',name,')'));
run;

 

Please guide me to do it. 

@Kurt_Bremser @Ksharp @Tom @yabwon @PaigeMiller 

3 REPLIES 3
yabwon
Onyx | Level 15

What's the error message? 

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



yabwon
Onyx | Level 15

When I'm sending multiple emails, I usually do it like this:

data Employee;
  input Name $ Email :$60.;
datalines;
John John@xyz.com
David david@xyz.com
Joe joe@xyz.com
;
run;
proc print;
run;

filename ELIST EMAIL
ENCODING = "UTF-8"
CONTENT_TYPE = 'text/html'
lrecl = 32767
;
data _NULL_;
  file ELIST;
  set Employee;

  /* new message tag */
  put '!EM_NEWMSG!'; 

  /* Title */
  put '!em_subject! ' "This is the subject.";

  /* Recipient */
  put '!em_to! ' email;

  /* Sender */
  put '!em_from! ' "FromWhom@email.com";
  put '!em_replyto! ' "replyTo@email.com";

  /* Content */
  put '<p> Dear ' Name '! </p>';
  put '<p> Have a great day! </p>';
  put '<p> Yours truly </br> Sastech </p>';

  /* send mail tag */
  put '!EM_SEND!'; 
  put '!EM_NEWMSG!'; 
  put '!EM_ABORT!'; 
run;

Bart

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



ballardw
Super User

Is your local email server complaining about you sending multiple emails, in effect creating SPAM?

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 814 views
  • 1 like
  • 3 in conversation