DATA Step, Macro, Functions and more

Macro Variable for Email Address

Reply
Super Contributor
Posts: 358

Macro Variable for Email Address

Hi All:

We have recently switched to Outlook as our e-mail system.  We also uses SAS to send SMTP e-mail messages.

How do I send an e-mail to 2 different people in the "to=" line?

Currently we use a macro variable to store the user address.  I think Outlook uses a semi-colon as the separator  to put between

the 2 addresses, but this becomes an invalid statement in SAS.

We code  -

call symput('emailaddr','name1@company.com;name2@company.com')   

to define the variable,

and then use:

FILE OUTBOXto="&emailaddr" 

but this does not work.

PROC Star
Posts: 1,322

Re: Macro Variable for Email Address

Hi,

I would try a space-delimited list of quoted email addresses, in parentheses i.e.

file outbox to=("mail1@company.com"  "mail2@company.com") ;

HTH,

--Q

Super Contributor
Posts: 334

Re: Macro Variable for Email Address

Just a question, it doesnt look like you are dynamically making the macro variable for the address. If not why not just code directly to the to line? Also the semicolon (in the macro variable) after the macro variable is resolved is probably being read by SAS to end the coding line and thus creating syntax errors. As quentin points out, and if memory serves, spaces should work fine.

Just some thoughts.

EJ

Occasional Contributor
Posts: 12

Re: Macro Variable for Email Address

Try This code I hope it works for you I just tested it seems ok to me.

%let to_list="mail1@server.com" "mail2@server.com";

%let path=W:;

filename myemail email to=(&to_list.)

cc="mail3@server.com"

bcc="mail4@server.com"

subject="Sending mail through SAS"

attach=("path.\SAS_Code.sas" "&path.\Copy of SAS_Code.sas")

;

data _null_;

file myemail;

put "Hi,Please find attached the two SAS Files.Thanks,Nishunk";

run;

Thanks,

Nishunk

Ask a Question
Discussion stats
  • 3 replies
  • 768 views
  • 0 likes
  • 4 in conversation