Help using Base SAS procedures

Reg:Sending Mail to Multiple users

Reply
Regular Contributor
Posts: 229

Reg:Sending Mail to Multiple users

Hi i am having a macro variable to send the email SEmailid I will write the email in one table from that it will pick it if i write for 1 email it was working user@email.com  then it was working if i want to send to 2-3 users it was not going i have tryed this ways %SEmailid=user1@gmail.com;user2@gmail.com;user3@gmail.com; %SEmailid=%str(user1@gmail.com;user2@gmail.com;user3@gmail.com); %SEmailid="user1@gmail.com" "user2@gmail.com" "user3@gmail.com" %SEmailid='user1@gmail.com' 'user2@gmail.com' 'user3@gmail.com'. can any one help me it was resloving but i ma not getting email for one email i am getting if i am trying for 2-3 emial is it was getting problem

Super User
Posts: 9,681

Reg:Sending Mail to Multiple users

What is your correct code when you can send only one E-mail addresss?

Regular Contributor
Posts: 229

Re: Reg:Sending Mail to Multiple users

%MACRO email(sEmailid);  FILENAME mymail EMAIL "NULL"  TO="&sEmailid"  SUBJECT="&pSubject";  data _null_;    FILE mymail;        END; run; %MEND; I the table i will give the email in the table user1@gmail.com DATA _NULL_ ;  CALL SYMPUT("pEmailid","&EMAIL_ID"); run; I am using DI 4.2

PROC Star
Posts: 7,363

Re: Reg:Sending Mail to Multiple users

In your example, not all email addresses end with a semi-colon.  That could be the problem.  If they do all end with semi-colons, have your tried ending them with commas instead?

Regular Contributor
Posts: 229

Re: Reg:Sending Mail to Multiple users

Tried semi colon(Smiley Wink and comma(,) also....

PROC Star
Posts: 7,363

Re: Reg:Sending Mail to Multiple users

I don't understand your code.  Is that what you actually submit?  You appear to create a macro, but don't call it and, rather, use call symput to create a macro variable.

Can you post two sets of code.  First, an entire set that will successfully produce a single email and then another full set that fails with multiple emails?

Regular Contributor
Regular Contributor
Posts: 166

Re: Reg:Sending Mail to Multiple users

Hi,

Two Possible ways that you can have a look at... Hope it helps


data a;
input mailid : $50. subject : $10.;
cards;
id1@mail.com test1
id2@mail.com test2
id3@mail.com test3
;
run;

*solution 1;
filename message email from = "mainid@mail.com";

data _null_;
file message;
set a;
put '!EM_TO!' mailid;
put '!EM_SUBJECT!' subject;
put "This is just a test";
put '!EM_SEND!';      
put '!EM_NEWMSG!';    
put '!EM_ABORT!';
run;


*Solution 2;
%MACRO email(pEmailid,psubject);
FILENAME mymail EMAIL
TO="&&pEmailid" 
SUBJECT="&&pSubject"
from="mainid@mail.com" ct='text/html';
data _null_;
FILE mymail; 
run;
%MEND;
DATA _NULL_ ;
set a;
call execute('%email('||mailid||' ,'||subject||')');
run;

Regular Contributor
Posts: 229

Re: Reg:Sending Mail to Multiple users

%MACRO email(SEmailid);   FILENAME mymail EMAIL "NULL"   TO="&SEmailid"     data _null_;     FILE mymail;         END; run; %MEND; OPTIONS MLOGIC MPRINT SYMBOLGEN; data _null_; set MailDset; call symput("V_EMAIL_ID",trim(EMAIL_ID)); run; DATA _NULL_ ;   CALL SYMPUT("SEmailid","&V_EMAIL_ID");   RUN; %email(&SEmailid); We are having a Dataset mailDest in that we have a variable called Email_ID there now we have only one email id now we want to insert 2-3 email ids we have tryed by keeping semicolon,comma(,),space and in code but i am getting error

Attachment
Regular Contributor
Regular Contributor
Posts: 166

Re: Reg:Sending Mail to Multiple users

Hi,

Is your objective to send the same mail to all the Ids in your data set ?

Then something that works for me is

proc sql;

select distinct quote(strip(email_id)) into : semailid separated by " "

from maildest;

quit;

%MACRO email(SEmailid);

  FILENAME mymail EMAIL

/*"NULL" */

  TO=

(

&SEmailid

)
from="myid@mail.com";

 

   data _null_;

    FILE mymail;

   

/*    END; */

run;

%MEND;

%email(&semailid);

Regular Contributor
Posts: 229

Re: Reg:Sending Mail to Multiple users

But i want to add the Email in the Table only as this is server for the above i should change it in many things actually in the previously i have added in the table only ,now also i wnat to add in the table only

Regular Contributor
Regular Contributor
Posts: 166

Re: Reg:Sending Mail to Multiple users


Please forgive me maybe i am unable to understand your problem...

Is it that you have a single cell in your table that will have all the emailids.....?

data maildset;
email_id = " 'id@mail.com' 'id2@mail.com' 'id3@mail.com' ";
run;

data _null_;
set MailDset;
call symput("SEmailid",trim(eMAIL_ID));
run;
%put &v_email_id;

%MACRO email(SEmailid);
  FILENAME mymail EMAIL

/*"NULL" */
  TO=
(
&SEmailid
);
   data _null_;
    FILE mymail;
   
   /*  END; */
run;
%MEND;
%email(&SEmailid);

If this does not help then probably you should post your log with the Mprint and Symbolgen so that the experts can look at it provide a solution.

Regular Contributor
Posts: 229

Re: Reg:Sending Mail to Multiple users

yes i have tryed startingly only. Actually i am having a table in that email variable is there now i want to add the new variables in to that cell only i have tryed by semicolon(Smiley Wink,comma(,) ,space like that

Regular Contributor
Regular Contributor
Posts: 166

Re: Reg:Sending Mail to Multiple users

It should be space with quotes. Please look at the sample that i have provided

data maildset;
email_id = " 'id@mail.com' 'id2@mail.com' 'id3@mail.com' ";
run;


However there seems to be a problem in the macro  Email that you have defined.

You need to change the TO =  your &semailid should be in brackets and not quote. Please check the sample provided above.

Ask a Question
Discussion stats
  • 12 replies
  • 742 views
  • 6 likes
  • 4 in conversation