<?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 how to send email to recipients that are stored in a table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-email-to-recipients-that-are-stored-in-a-table/m-p/379252#M91273</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to send emails to multiple recepients (with attachments) using the email addresses that are stored in the data set. Following is the code that I've used and the error message that I am getting.. please advise&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;---------------------CODE that I used - --------------------------------------------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data TBL_EMAIL;&lt;BR /&gt;input&lt;BR /&gt;nuid $ 1-7&lt;BR /&gt;email_address $ 9-28&lt;BR /&gt;report_id $ 32-33&lt;BR /&gt;objectname $ 34-47&lt;BR /&gt;objecttype $ 49-64;&lt;BR /&gt;cards;&lt;BR /&gt;A111111 myemail@Domain.com 1 test report report&lt;BR /&gt;A111112 myemail@Domain.com 2 test report report&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro email(emailid);&lt;BR /&gt;FILENAME Mailbox EMAIL "&amp;amp;emailid"&lt;BR /&gt;Subject='Report - Ran okay' &lt;BR /&gt;ATTACH="M:\Monthly\Report.xlsx"; &lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;FILE Mailbox;&lt;BR /&gt;PUT "Hello";&lt;BR /&gt;PUT "Please find the Report as an attachment";&lt;BR /&gt;PUT "Thank you";&lt;BR /&gt;PUT " ";&lt;BR /&gt;RUN;&lt;BR /&gt;%mend email;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro email_error;&lt;BR /&gt;FILENAME Mailbox EMAIL 'xx@yy.com'&lt;BR /&gt;Subject='Report - Error' ;&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;FILE Mailbox;&lt;BR /&gt;PUT "Hello";&lt;BR /&gt;PUT "Please be advised that Report was generated with potential errors";&lt;BR /&gt;PUT "Thank you";&lt;BR /&gt;PUT " ";&lt;BR /&gt;RUN;&lt;BR /&gt;%mend email_error;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Table2a_;&lt;BR /&gt;set Table2(where = (&lt;BR /&gt;&lt;SPAN&gt;report_id&lt;/SPAN&gt; = 14 &lt;BR /&gt;) );&lt;BR /&gt;if 180000 &amp;lt;= price &amp;lt;= 300000 &lt;BR /&gt;then call execute ('data _null_; set TBL_EMAIL; where report_id=1; %email('||email_address||'); run;');&lt;BR /&gt;else call execute ('%email_error');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;----------------Error Message that I got ------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The file MAILBOX is:&lt;BR /&gt;E-Mail Access Device&lt;/P&gt;
&lt;P&gt;ERROR: Invalid E-mail recipient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-----------------------What worked ------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Following code worked (&lt;STRONG&gt;suggesting that there is something wrong in a way I am calling the email macro&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data Table2a_;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set Table2(where = (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;location_ID = 14&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;) );&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if 180000 &amp;lt;= price &amp;lt;= 300000&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;then call execute ('%email(myemail@Domain.com)');&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;else call execute ('%email_error');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2017 01:24:40 GMT</pubDate>
    <dc:creator>tparvaiz</dc:creator>
    <dc:date>2017-07-26T01:24:40Z</dc:date>
    <item>
      <title>how to send email to recipients that are stored in a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-email-to-recipients-that-are-stored-in-a-table/m-p/379252#M91273</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to send emails to multiple recepients (with attachments) using the email addresses that are stored in the data set. Following is the code that I've used and the error message that I am getting.. please advise&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;---------------------CODE that I used - --------------------------------------------------&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data TBL_EMAIL;&lt;BR /&gt;input&lt;BR /&gt;nuid $ 1-7&lt;BR /&gt;email_address $ 9-28&lt;BR /&gt;report_id $ 32-33&lt;BR /&gt;objectname $ 34-47&lt;BR /&gt;objecttype $ 49-64;&lt;BR /&gt;cards;&lt;BR /&gt;A111111 myemail@Domain.com 1 test report report&lt;BR /&gt;A111112 myemail@Domain.com 2 test report report&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro email(emailid);&lt;BR /&gt;FILENAME Mailbox EMAIL "&amp;amp;emailid"&lt;BR /&gt;Subject='Report - Ran okay' &lt;BR /&gt;ATTACH="M:\Monthly\Report.xlsx"; &lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;FILE Mailbox;&lt;BR /&gt;PUT "Hello";&lt;BR /&gt;PUT "Please find the Report as an attachment";&lt;BR /&gt;PUT "Thank you";&lt;BR /&gt;PUT " ";&lt;BR /&gt;RUN;&lt;BR /&gt;%mend email;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro email_error;&lt;BR /&gt;FILENAME Mailbox EMAIL 'xx@yy.com'&lt;BR /&gt;Subject='Report - Error' ;&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;FILE Mailbox;&lt;BR /&gt;PUT "Hello";&lt;BR /&gt;PUT "Please be advised that Report was generated with potential errors";&lt;BR /&gt;PUT "Thank you";&lt;BR /&gt;PUT " ";&lt;BR /&gt;RUN;&lt;BR /&gt;%mend email_error;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data Table2a_;&lt;BR /&gt;set Table2(where = (&lt;BR /&gt;&lt;SPAN&gt;report_id&lt;/SPAN&gt; = 14 &lt;BR /&gt;) );&lt;BR /&gt;if 180000 &amp;lt;= price &amp;lt;= 300000 &lt;BR /&gt;then call execute ('data _null_; set TBL_EMAIL; where report_id=1; %email('||email_address||'); run;');&lt;BR /&gt;else call execute ('%email_error');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;----------------Error Message that I got ------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;NOTE: The file MAILBOX is:&lt;BR /&gt;E-Mail Access Device&lt;/P&gt;
&lt;P&gt;ERROR: Invalid E-mail recipient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-----------------------What worked ------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Following code worked (&lt;STRONG&gt;suggesting that there is something wrong in a way I am calling the email macro&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data Table2a_;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set Table2(where = (&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;location_ID = 14&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;) );&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if 180000 &amp;lt;= price &amp;lt;= 300000&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;then call execute ('%email(myemail@Domain.com)');&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;else call execute ('%email_error');&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 01:24:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-send-email-to-recipients-that-are-stored-in-a-table/m-p/379252#M91273</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-07-26T01:24:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to send email to recipients that are stored in a table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-email-to-recipients-that-are-stored-in-a-table/m-p/379253#M91274</link>
      <description>&lt;P&gt;Could you please share the log with the exact error message you are getting&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;also please try this , I am expecting that in the dataset you are passing you have the email_address variable with emailid's.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Table2a_;
set Table2(where = (
location_ID = 14 
) );
if 180000 &amp;lt;= price &amp;lt;= 300000 
then call execute ('%email('||email_address||')');
else call execute ('%email_error');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 26 Jul 2017 01:36:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-send-email-to-recipients-that-are-stored-in-a-table/m-p/379253#M91274</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-07-26T01:36:59Z</dc:date>
    </item>
  </channel>
</rss>

