how to send email with 2 different subject messages like conditional email

Reply
Contributor
Posts: 20

how to send email with 2 different subject messages like conditional email

Hi All,

 

How can i send a conditional email with different subject messages .Can you please help me out as im trying to execute my job in batch mode and trying to send emails based on success/unsuceesful of job ! i tried below but it is going to else statement even if the if statement is true.

FILENAME TEMP EMAIL TO=(
"person@yahoocom"
)
;

DATA _NULL_;
set my_log1;
IF &count1.=0 then do;
FILE TEMP
subject="PBDV report Successfull for &run_date." ;
PUT 'PLEASE VIEW THE REPORT IN THE REPORTING PORTAL ' ;
PUT ;
today = put(date(),worddate18.);
PUT ' ' today;
PUT ;
end;
else
do;
file temp
subject="PBDV report not Successfull for &run_date.";
PUT "PBDV REPORT FAILED FOR &run_date." ;
PUT ;
Put ' This e-mail is an automated notification!';
PUT ;
PUT 'DO NOT REPLY TO THIS MESSAGE ';
Put '=============================================';
Put ' Please contact:';
Put ' .person.@yahoo.com

' ;
Put ' if you have any questions or concerns.' ;
Put '=============================================';
Put ;
end;

RUN;

Respected Advisor
Posts: 4,173

Re: how to send email with 2 different subject messages like conditional email

@Deepti44

With an IF..THEN ..ELSE as you've done it. 

What is not working?

Contributor
Posts: 20

Re: how to send email with 2 different subject messages like conditional email

even IF statement is true , it is going to else staement and sending subject of the email  "as  job not successfull ".

Respected Advisor
Posts: 4,173

Re: how to send email with 2 different subject messages like conditional email

@Deepti44

If you're testing with the code you've posted then I don't see how this could happen.

 

Are you sure your macro variable contains a 0 when you believe the condition should be TRUE?

 

Use options symbolgen; to see in the Log to what your macro var resolves;

 

For test purposes populate the macro variable manually right before the data step

%let count1=0;

 

 

 

Contributor
Posts: 20

Re: how to send email with 2 different subject messages like conditional email

yes my count1 is resolving to 0, i have double checked but not sure why it is going to else part!

Respected Advisor
Posts: 4,173

Re: how to send email with 2 different subject messages like conditional email

post your log (as attachment)

Contributor
Posts: 20

Re: how to send email with 2 different subject messages like conditional email

I have used Email directives from SAS and it worked, i just replaced current subject with the new one's.

 

 

Ask a Question
Discussion stats
  • 6 replies
  • 129 views
  • 0 likes
  • 2 in conversation