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 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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