DATA Step, Macro, Functions and more

How to send SAS email to multiple participants

Accepted Solution Solved
Reply
Contributor
Posts: 29
Accepted Solution

How to send SAS email to multiple participants

I've a macro variable as

 

 

%let emails = "A@sas.com B@sas.com";

 

options emailsys=smtp emailhost=domain.com  emailport=25; 
			filename outbox EMAIL;

			data _null_;
				
				file outbox
				TO=(&emails)
				FROM =('sas_noreply@domain.com') 
				type="text/html"
				subject=("SAS ALERT:");

				put '<html>';
				put '<body>';
				put '<div>';
				put '<p>Message Body</p>
				put '</div>';
				put '</body>';
				put '</html>';
			run;

and I'm sending it using the upper code

I receive the error that email is bad.

 

I've tried

"'a@sas.com' 'b@sas.com'"

"a@sas.om b@sas.com"

("a@sas.om b@sas.com")

 

Kindly provide support. 

Please note, I've only a macro variable containing list of comma separated emails.

 

 

 

Comma separated mails are working in "CC" but in "TO" system throws error

 

ERROR: Email: 501 Syntax error, parameters in command "RCPT
       TO:<a@sas.com,b@sas.com>" unrecognized or missing
WARNING: Bad e-mail address: (a@sas.com,b@sas.com)
WARNING: No email addresses specified.

 


Accepted Solutions
Solution
2 weeks ago
Super User
Posts: 10,217

Re: How to send SAS email to multiple participants

Just a tiny change in your %let:

%let emails = "A@sas.com" "B@sas.com";

and

filename outbox email
  to=(&emails)
  from =('sas_noreply@domain.com') 
  type="text/html"
  subject=("SAS ALERT:")
;

data _null_;
file outbox;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
2 weeks ago
Super User
Posts: 10,217

Re: How to send SAS email to multiple participants

Just a tiny change in your %let:

%let emails = "A@sas.com" "B@sas.com";

and

filename outbox email
  to=(&emails)
  from =('sas_noreply@domain.com') 
  type="text/html"
  subject=("SAS ALERT:")
;

data _null_;
file outbox;
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
PROC Star
Posts: 263

Re: How to send SAS email to multiple participants

I think your macro variable should contain a list of quoted mail adresses, e.g.

%let emails="A@sas.com" "B@sas.com";
TO=(&emails)
Contributor
Posts: 29

Re: How to send SAS email to multiple participants

Thanks a lot Everyone for Quick response. It's working. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 78 views
  • 0 likes
  • 3 in conversation