<?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 emails to recipients extracted from the dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/363199#M85944</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using following code to generate email.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;----------------------------------------------------------------CODE-------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro email;&lt;BR /&gt;FILENAME Mailbox EMAIL 'xyz@hotmail.com'&lt;BR /&gt; Subject='Report - Ran okay' ; &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;/P&gt;
&lt;P&gt;%mend email;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro email_error;&lt;BR /&gt;FILENAME Mailbox EMAIL '&lt;SPAN&gt;xyz@hotmail.com&lt;/SPAN&gt;'&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;/P&gt;
&lt;P&gt;%mend email_error;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data Table2a_;&lt;BR /&gt; set Table2(where = (&lt;BR /&gt;location_ID&amp;nbsp;= 14 &lt;BR /&gt; ) );&lt;BR /&gt; if 180000 &amp;lt;= price&amp;nbsp;&amp;lt;= 300000 then call execute ('%email');else call execute ('%email_error');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;------------------------------------------------------&lt;/P&gt;
&lt;P&gt;may I know how to use email addresses from a dataset rather than defining it in the code. for example, let's say I have a dataset TBL_EMAIL that looks something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Report_ID &amp;nbsp;email_address&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc@hotmail.com&lt;/P&gt;
&lt;P&gt;1&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xyz@hotmail.com&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;2&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc@hotmail.com&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;so I want to send the report to all the email addresses where report id = 1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;please advise&lt;/SPAN&gt;&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, 31 May 2017 19:52:07 GMT</pubDate>
    <dc:creator>tparvaiz</dc:creator>
    <dc:date>2017-05-31T19:52:07Z</dc:date>
    <item>
      <title>how to send emails to recipients extracted from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/363199#M85944</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using following code to generate email.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;----------------------------------------------------------------CODE-------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro email;&lt;BR /&gt;FILENAME Mailbox EMAIL 'xyz@hotmail.com'&lt;BR /&gt; Subject='Report - Ran okay' ; &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;/P&gt;
&lt;P&gt;%mend email;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro email_error;&lt;BR /&gt;FILENAME Mailbox EMAIL '&lt;SPAN&gt;xyz@hotmail.com&lt;/SPAN&gt;'&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;/P&gt;
&lt;P&gt;%mend email_error;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data Table2a_;&lt;BR /&gt; set Table2(where = (&lt;BR /&gt;location_ID&amp;nbsp;= 14 &lt;BR /&gt; ) );&lt;BR /&gt; if 180000 &amp;lt;= price&amp;nbsp;&amp;lt;= 300000 then call execute ('%email');else call execute ('%email_error');&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;------------------------------------------------------&lt;/P&gt;
&lt;P&gt;may I know how to use email addresses from a dataset rather than defining it in the code. for example, let's say I have a dataset TBL_EMAIL that looks something like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Report_ID &amp;nbsp;email_address&lt;/P&gt;
&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc@hotmail.com&lt;/P&gt;
&lt;P&gt;1&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xyz@hotmail.com&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;2&lt;SPAN&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; abc@hotmail.com&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;so I want to send the report to all the email addresses where report id = 1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;please advise&lt;/SPAN&gt;&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, 31 May 2017 19:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/363199#M85944</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-31T19:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: how to send emails to recipients extracted from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/363272#M85990</link>
      <description>&lt;P&gt;this is an untested code, hopefully will work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro email(emailid);
FILENAME Mailbox EMAIL "&amp;amp;emailid"
Subject='Report - Ran okay' ; 
DATA _NULL_;
FILE Mailbox;
PUT "Hello";
PUT "Please find the Report as an attachment";
PUT "Thank you";
PUT " ";
RUN;
%mend email;

%macro email_error(emailid);
FILENAME Mailbox EMAIL "&amp;amp;emailid"
Subject='Report - Error' ;
DATA _NULL_;
FILE Mailbox;
PUT "Hello";
PUT "Please be advised that Report was generated with potential errors";
PUT "Thank you";
PUT " ";
RUN;
%mend email_error;

data Table2a_;
set Table2(where = (
location_ID&amp;nbsp;= 14 
) );
if 180000 &amp;lt;= price&amp;nbsp;&amp;lt;= 300000 then call execute ('%email('||email_address||')');else call execute ('%email_error('||email_address||')');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 31 May 2017 23:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/363272#M85990</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-05-31T23:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to send emails to recipients extracted from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/363275#M85992</link>
      <description>&lt;P&gt;How is it calling&amp;nbsp;&lt;SPAN&gt;TBL_EMAIL.EMAIL_ADDRESS&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;can you please advise&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 23:59:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/363275#M85992</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-05-31T23:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: how to send emails to recipients extracted from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/363281#M85997</link>
      <description>&lt;P&gt;We need to use the dataset which has the email id&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 ('data _null_; set TBL_EMAIL; where report_id=1; %email('||email_address||'); run;');else call execute ('data _null_; set TBL_EMAIL; where report_id^=1;%email_error('||email_address||');run;');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jun 2017 01:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/363281#M85997</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2017-06-01T01:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to send emails to recipients extracted from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/377091#M90534</link>
      <description>&lt;P&gt;Here is the code that&amp;nbsp;failed and generated an error message&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;---------------------CODE that I used - --------------------------------------------------&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;location_ID = 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>Tue, 18 Jul 2017 18:26:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/377091#M90534</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-07-18T18:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to send emails to recipients extracted from the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/377093#M90535</link>
      <description>&lt;P&gt;here is how I am creating a test table&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data TBL_EMAIL;&lt;BR /&gt; input&lt;/P&gt;
&lt;P&gt;nuid $ 1-7&lt;BR /&gt; email_address $ 9-28&lt;BR /&gt;&lt;SPAN&gt;report_id&lt;/SPAN&gt; $ 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;</description>
      <pubDate>Tue, 18 Jul 2017 18:29:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-send-emails-to-recipients-extracted-from-the-dataset/m-p/377093#M90535</guid>
      <dc:creator>tparvaiz</dc:creator>
      <dc:date>2017-07-18T18:29:42Z</dc:date>
    </item>
  </channel>
</rss>

