I am needing to find out how to send email via unix SAS. PC SAS is so easy, but it seems much harder in the UNIX SAS environment.
Any ideas or code examples???
I was give the example below but I don't have a firm grasp of what is going on in this program.
/*---------------------------------------------------------------------+
Macro: emailMsg
Parms: msgSubject - subject line of the email.
msg - body of the email msg.
type - TEXT, FILE, or PIPE. TEXT the body of the email msg
can be handled as a text string. FILE the body of the
email message is in a file that needs to be
concatenated to the email message. PIPE the body of
the email message will come from a UNIX command that
needs to be executed and the output redirected to the
body of the email.
This macro uses the sendmail command to email a message from within
a SAS program. The message body can be a text string, the contents
of a file or the output of a UNIX command. The macro expects to
find a file named email.header in the working directory. This file
contains the From: and To: portions of the email in the format:
From: "YourName"
To: jane.doe@company.com, john.doe@company.com
The "YourName" portion of the email.header will be displayed as who
the email is coming from and does need to be in quotes. The To: portion
of the email can contain one or more comma separated email addresses.
+--------------------------------------------------------------------*/
%macro emailMsg(msgSubject, msg, type);
%local quote;
%let quote = %str(%');
%if ( %scan(&msg,1,%str( )) eq ) %then %do;
%sysexec echo "e.Subject:&msgSubject.\n\n"e |
cat email.header - |
sendmail -f va2pwap010@company.com -t;
%end;
%else %if ( %scan(&type,1,%str( )) eq ) or
( %scan(&type,1,%str( )) eq TEXT) %then %do;
%sysexec echo "e.Subject:&msgSubject.\n\n"e"e.&msg."e |
cat email.header - |
sendmail -f va2pwap010@company.com -t;
%end;
%else %if ( %scan(&type,1,%str( )) eq FILE ) %then %do;
%sysexec echo "e.Subject:&msgSubject.\n\n"e"e.&msg."e |
cat email.header &msg - |
sendmail -f va2pwap010@company.com -t;
%end;
%else %if ( %scan(&type,1,%str( )) eq PIPE ) %then %do;
%sysexec %str(&msg > .temp; )
echo "e.Subject:&msgSubject.\n\n"e"e.Program:&msg."e |
cat email.header - .temp |
sendmail -f va2pwap010@company.com -t;
%end;
%mend emailMsg;
Message was edited by: darrenst at May 24, 2006 3:40 PM