BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Azeem112
Quartz | Level 8

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.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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;

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

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;
s_lassen
Meteorite | Level 14

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)
Azeem112
Quartz | Level 8

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 19354 views
  • 0 likes
  • 3 in conversation