Simple email logic behaves odd

Reply
Occasional Contributor
Posts: 5

Simple email logic behaves odd

Pretty Simple logic, performs email send independant of IF logic:

 

Code snippet

data _null_;
  if  1=0 then do;
      options emailsys=MAPI emailid=first.last;
      filename mailbox email;
      file mailbox to='first.last@xx.com' subject='MAPI test II';
      put "email sent";
    end;
  else do;
      put "email not sent";
  end;
run;

Corresponding Log output

email not sent
Message sent
      To:          first.last@xx.com
      Cc:
      Bcc:
      Subject:     MAPI test II
      Attachments:

SAS Super FREQ
Posts: 683

Re: Simple email logic behaves odd

there are no records written to the file "mailbox". however the file is "touched" (open and close of file) and this action sends the email.

 

what condition to you need to test?

Occasional Contributor
Posts: 5

Re: Simple email logic behaves odd

I assumed that the filename statement would be skipped by the failure of the condition, the condition is the existence of an error code.
SAS Super FREQ
Posts: 683

Re: Simple email logic behaves odd

The OPTIONS and FILENAME statements are global statements they can not be executed using a DATA Step IF. I suggest to use Macro coding to check for the condition and then executed the complete DATA Step based on the condition.

Occasional Contributor
Posts: 5

Re: Simple email logic behaves odd

That is it, embedding the global statements in a macro recognized the condition.

 

Many thanks,

WW

Ask a Question
Discussion stats
  • 4 replies
  • 4624 views
  • 0 likes
  • 2 in conversation