<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Sending email via UNIX SAS in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Sending-email-via-UNIX-SAS/m-p/694#M1507</link>
    <description>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.&lt;BR /&gt;
&lt;BR /&gt;
Any ideas or code examples???&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I was give the example below but I don't have a firm grasp of what is going on in this program.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/*---------------------------------------------------------------------+&lt;BR /&gt;
  Macro: emailMsg&lt;BR /&gt;
  Parms: msgSubject - subject line of the email.&lt;BR /&gt;
msg - body of the email msg.&lt;BR /&gt;
type - TEXT, FILE, or PIPE.  TEXT the body of the email msg&lt;BR /&gt;
                can be handled as a text string.  FILE the body of the&lt;BR /&gt;
                email message is in a file that needs to be &lt;BR /&gt;
                concatenated to the email message. PIPE the body of   &lt;BR /&gt;
                the email message will come from a UNIX command that&lt;BR /&gt;
                needs to be executed and the output redirected to the&lt;BR /&gt;
                body of the email.&lt;BR /&gt;
&lt;BR /&gt;
  This macro uses the sendmail command to email a message from within&lt;BR /&gt;
  a SAS program.  The message body can be a text string, the contents&lt;BR /&gt;
  of a file or the output of a  UNIX command.  The macro expects to&lt;BR /&gt;
  find a file named email.header in the working directory.  This file&lt;BR /&gt;
  contains the From: and To: portions of the email in the format:&lt;BR /&gt;
&lt;BR /&gt;
     From: "YourName" &lt;VA2PWAP010&gt;&lt;BR /&gt;
     To: jane.doe@company.com, john.doe@company.com&lt;BR /&gt;
&lt;BR /&gt;
  The "YourName" portion of the email.header will be displayed as who&lt;BR /&gt;
  the email is coming from and does need to be in quotes.  The To: portion&lt;BR /&gt;
  of the email can contain one or more comma separated email addresses.&lt;BR /&gt;
 +--------------------------------------------------------------------*/&lt;BR /&gt;
%macro emailMsg(msgSubject, msg, type);&lt;BR /&gt;
&lt;BR /&gt;
   %local quote;&lt;BR /&gt;
   %let quote = %str(%');&lt;BR /&gt;
&lt;BR /&gt;
   %if ( %scan(&amp;amp;msg,1,%str( )) eq ) %then %do;&lt;BR /&gt;
&lt;BR /&gt;
      %sysexec echo &amp;amp;quote.Subject:&amp;amp;msgSubject.\n\n&amp;amp;quote |&lt;BR /&gt;
               cat email.header - |&lt;BR /&gt;
               sendmail -f va2pwap010@company.com -t;&lt;BR /&gt;
   %end;&lt;BR /&gt;
   %else %if ( %scan(&amp;amp;type,1,%str( )) eq ) or&lt;BR /&gt;
            ( %scan(&amp;amp;type,1,%str( )) eq TEXT) %then %do;&lt;BR /&gt;
&lt;BR /&gt;
      %sysexec echo &amp;amp;quote.Subject:&amp;amp;msgSubject.\n\n&amp;amp;quote&amp;amp;quote.&amp;amp;msg.&amp;amp;quote |&lt;BR /&gt;
               cat email.header - |&lt;BR /&gt;
               sendmail -f va2pwap010@company.com -t;&lt;BR /&gt;
   %end;&lt;BR /&gt;
   %else %if ( %scan(&amp;amp;type,1,%str( )) eq FILE ) %then %do;&lt;BR /&gt;
&lt;BR /&gt;
      %sysexec echo &amp;amp;quote.Subject:&amp;amp;msgSubject.\n\n&amp;amp;quote&amp;amp;quote.&amp;amp;msg.&amp;amp;quote |&lt;BR /&gt;
               cat email.header &amp;amp;msg - |&lt;BR /&gt;
               sendmail -f va2pwap010@company.com -t;&lt;BR /&gt;
   %end;&lt;BR /&gt;
   %else %if ( %scan(&amp;amp;type,1,%str( )) eq PIPE ) %then %do;&lt;BR /&gt;
&lt;BR /&gt;
      %sysexec %str(&amp;amp;msg &amp;gt; .temp; )&lt;BR /&gt;
        echo &amp;amp;quote.Subject:&amp;amp;msgSubject.\n\n&amp;amp;quote&amp;amp;quote.Program:&amp;amp;msg.&amp;amp;quote |&lt;BR /&gt;
        cat email.header - .temp |&lt;BR /&gt;
        sendmail -f va2pwap010@company.com -t;&lt;BR /&gt;
   %end;&lt;BR /&gt;
%mend emailMsg;

&lt;BR /&gt;
Message was edited by: darrenst at May 24, 2006 3:40 PM&lt;BR /&gt;&lt;/VA2PWAP010&gt;</description>
    <pubDate>Wed, 24 May 2006 19:39:49 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2006-05-24T19:39:49Z</dc:date>
    <item>
      <title>Sending email via UNIX SAS</title>
      <link>https://communities.sas.com/t5/Developers/Sending-email-via-UNIX-SAS/m-p/694#M1507</link>
      <description>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.&lt;BR /&gt;
&lt;BR /&gt;
Any ideas or code examples???&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I was give the example below but I don't have a firm grasp of what is going on in this program.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
/*---------------------------------------------------------------------+&lt;BR /&gt;
  Macro: emailMsg&lt;BR /&gt;
  Parms: msgSubject - subject line of the email.&lt;BR /&gt;
msg - body of the email msg.&lt;BR /&gt;
type - TEXT, FILE, or PIPE.  TEXT the body of the email msg&lt;BR /&gt;
                can be handled as a text string.  FILE the body of the&lt;BR /&gt;
                email message is in a file that needs to be &lt;BR /&gt;
                concatenated to the email message. PIPE the body of   &lt;BR /&gt;
                the email message will come from a UNIX command that&lt;BR /&gt;
                needs to be executed and the output redirected to the&lt;BR /&gt;
                body of the email.&lt;BR /&gt;
&lt;BR /&gt;
  This macro uses the sendmail command to email a message from within&lt;BR /&gt;
  a SAS program.  The message body can be a text string, the contents&lt;BR /&gt;
  of a file or the output of a  UNIX command.  The macro expects to&lt;BR /&gt;
  find a file named email.header in the working directory.  This file&lt;BR /&gt;
  contains the From: and To: portions of the email in the format:&lt;BR /&gt;
&lt;BR /&gt;
     From: "YourName" &lt;VA2PWAP010&gt;&lt;BR /&gt;
     To: jane.doe@company.com, john.doe@company.com&lt;BR /&gt;
&lt;BR /&gt;
  The "YourName" portion of the email.header will be displayed as who&lt;BR /&gt;
  the email is coming from and does need to be in quotes.  The To: portion&lt;BR /&gt;
  of the email can contain one or more comma separated email addresses.&lt;BR /&gt;
 +--------------------------------------------------------------------*/&lt;BR /&gt;
%macro emailMsg(msgSubject, msg, type);&lt;BR /&gt;
&lt;BR /&gt;
   %local quote;&lt;BR /&gt;
   %let quote = %str(%');&lt;BR /&gt;
&lt;BR /&gt;
   %if ( %scan(&amp;amp;msg,1,%str( )) eq ) %then %do;&lt;BR /&gt;
&lt;BR /&gt;
      %sysexec echo &amp;amp;quote.Subject:&amp;amp;msgSubject.\n\n&amp;amp;quote |&lt;BR /&gt;
               cat email.header - |&lt;BR /&gt;
               sendmail -f va2pwap010@company.com -t;&lt;BR /&gt;
   %end;&lt;BR /&gt;
   %else %if ( %scan(&amp;amp;type,1,%str( )) eq ) or&lt;BR /&gt;
            ( %scan(&amp;amp;type,1,%str( )) eq TEXT) %then %do;&lt;BR /&gt;
&lt;BR /&gt;
      %sysexec echo &amp;amp;quote.Subject:&amp;amp;msgSubject.\n\n&amp;amp;quote&amp;amp;quote.&amp;amp;msg.&amp;amp;quote |&lt;BR /&gt;
               cat email.header - |&lt;BR /&gt;
               sendmail -f va2pwap010@company.com -t;&lt;BR /&gt;
   %end;&lt;BR /&gt;
   %else %if ( %scan(&amp;amp;type,1,%str( )) eq FILE ) %then %do;&lt;BR /&gt;
&lt;BR /&gt;
      %sysexec echo &amp;amp;quote.Subject:&amp;amp;msgSubject.\n\n&amp;amp;quote&amp;amp;quote.&amp;amp;msg.&amp;amp;quote |&lt;BR /&gt;
               cat email.header &amp;amp;msg - |&lt;BR /&gt;
               sendmail -f va2pwap010@company.com -t;&lt;BR /&gt;
   %end;&lt;BR /&gt;
   %else %if ( %scan(&amp;amp;type,1,%str( )) eq PIPE ) %then %do;&lt;BR /&gt;
&lt;BR /&gt;
      %sysexec %str(&amp;amp;msg &amp;gt; .temp; )&lt;BR /&gt;
        echo &amp;amp;quote.Subject:&amp;amp;msgSubject.\n\n&amp;amp;quote&amp;amp;quote.Program:&amp;amp;msg.&amp;amp;quote |&lt;BR /&gt;
        cat email.header - .temp |&lt;BR /&gt;
        sendmail -f va2pwap010@company.com -t;&lt;BR /&gt;
   %end;&lt;BR /&gt;
%mend emailMsg;

&lt;BR /&gt;
Message was edited by: darrenst at May 24, 2006 3:40 PM&lt;BR /&gt;&lt;/VA2PWAP010&gt;</description>
      <pubDate>Wed, 24 May 2006 19:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Sending-email-via-UNIX-SAS/m-p/694#M1507</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-05-24T19:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sending email via UNIX SAS</title>
      <link>https://communities.sas.com/t5/Developers/Sending-email-via-UNIX-SAS/m-p/695#M1508</link>
      <description>It should be a lot more straightforward than the example you detail here.  Just try using the FILENAME statement with the EMAIL keyword:&lt;BR /&gt;
&lt;BR /&gt;
filename mymail email "JBrown@site.com"&lt;BR /&gt;
   subject="My SAS Configuration File"&lt;BR /&gt;
   attach="/u/sas/sasv8.cfg";&lt;BR /&gt;
&lt;BR /&gt;
data _null_;&lt;BR /&gt;
   file mymail;&lt;BR /&gt;
   put 'Jim,';&lt;BR /&gt;
   put 'This is my SAS configuration file.';&lt;BR /&gt;
   put 'I think you might like the';&lt;BR /&gt;
   put 'new options I added.';&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
I copied this from the online docs where you can find all the various options.  We use this method on UNIX and it works perfectly.</description>
      <pubDate>Wed, 31 May 2006 21:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Sending-email-via-UNIX-SAS/m-p/695#M1508</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2006-05-31T21:48:35Z</dc:date>
    </item>
  </channel>
</rss>

