<?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 Email from a data step with dynamic mailing list in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/438279#M28313</link>
    <description>&lt;P&gt;Hi there, this is my first time posting a question online I usually stick to lurking and finding similar queries to my own but alas I am having a world of difficulty setting the email configurations up in SAS EG so that I&amp;nbsp;can get&amp;nbsp;the program up and Running.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thank you all for all the help you provide the community I've found a ton of info already thanks to you all.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My goal is to have&amp;nbsp;an automated program that is&amp;nbsp;scheduled for&amp;nbsp;a user,&amp;nbsp;upon being started it will&amp;nbsp;conclude a set of predetermined tasks&amp;nbsp;and email the user that made the request the results of the task.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Now I have everything ready but the last piece of the puzzle is the email part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot use the&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;send to -&amp;gt; Email Recipient as a Step in Project&lt;/STRONG&gt;&amp;nbsp;&lt;/EM&gt;because as far as I can tell I can't give it a dynamic variable for it to use as the email recipient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select c_email
		into :email
		from USER_INFO
		;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I create the email variable with the above code and then wish to use it for sending the the email to the recipient &amp;amp;email.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now my companies email is a outlook base email from the office 365 schema.&lt;/P&gt;&lt;P&gt;So I though using the MAPI solution would be enough for me and it works fine when I run the task straight from SAS EG.&lt;BR /&gt;But when the program is invoked as a scheduled task from a user request it does not run the email program. But it doesn't specify the error either. It just has a cross mark on the program.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options
emailsys="MAPI"
EMAILID="xxx.yyy@company.com"
EMAILAUTHPROTOCOL=none
;

FILENAME Mailbox EMAIL 'xxx.yyy@company.com'
Subject='STARTUP';
DATA _NULL_;
FILE Mailbox;
PUT "Hello";
PUT "This is a test message from the DATA step";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 63px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18666i25F03DCD92F95FFD/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&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;So I've tested a few solutions SMTP connection with my GMAIL account for testing, MAPI with the companies Outlook client and using the E-mail Recipient step.&lt;BR /&gt;The gmail connection through SMTP works fine run directly from the task and invoked as a scheduled request from a user:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options
emailsys="smtp"
EMAILHOST="smtp.gmail.com"
EMAILPORT=25
EMAILID="xxx.yyy@gmail.com"
EMAILAUTHPROTOCOL=plain
EMAILPW="{SAS002}xxxx"
;

options emailhost=
 (
   "smtp.gmail.com" 
   /* alternate: port=487 SSL */
   port=587 STARTTLS 
   auth=plain 
   /* your Gmail address */
   id="xxx.yyy@gmail.com"
   /* optional: encode PW with PROC PWENCODE */
   pw="{SAS002}xxxx" 
 )
;
 
filename myemail EMAIL
  to=("&amp;amp;mail")
  subject="abc - Request from &amp;amp;user"
  attach	=	'C:\Desktop\abc.csv';
 
data _null_;
  file myemail;
  put "Dear User,";
  put "The request information is annexed in the current email";
  put "Best Regards,";
  put "xxx";
run;
 
filename myemail clear;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now this is where I am stuck right now because from what I can the the E-mail Recipient also use a SMTP connection but I cannot replicate it by script. It also uses Windows authentication.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 105px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18667i12C868EF4BA136F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 531px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18668i1EF1DE3EC6CD2315/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So now how do I replicate the connection that this module is using by script?&lt;BR /&gt;&lt;BR /&gt;I tried the following, but I get an&amp;nbsp;ERROR: Email: The connection was refused.&lt;BR /&gt;The code I tried was as follow and I tried to mimic the gmail script:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options
emailsys="smtp"
EMAILHOST="mail.company.com"
EMAILPORT=25
EMAILID="xxx.yyy@company.com"
EMAILAUTHPROTOCOL=plain
EMAILPW="{SAS002}xxxx"
;

options emailhost=
 (
   "mail.company.com" 
   /* alternate: port=487 SSL */
   port=587 STARTTLS 
   auth=plain 
   id="xxx.yyy@company.com"
   /* optional: encode PW with PROC PWENCODE */
   pw="{SAS002}xxxx" 
 )
;

FILENAME Mailbox EMAIL 'xxx.yyy@company.com'
 Subject='STARTUP';
DATA _NULL_;
FILE Mailbox;
PUT "Hello";
PUT "This is a test message from the DATA step";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with auth =&amp;nbsp;none I get&amp;nbsp;ERROR: Email: 530 5.7.1 Client was not authenticated.&lt;BR /&gt;And I know that this probably means that I cannot use an SSL&amp;nbsp; to TLS request. But I just can't&amp;nbsp;understand how to use the Windows Integrated authentication for the SMTP request the same that the E-mail Recipient does ...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any help on understanding why using MAPI isn't working as a scheduled taks or why I can use my account with a SMTP request from the E-MAIL Recipient task but can't replicate it by code on a data step would be apreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some of my reading material can be found here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings13/023-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/023-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/340-2013.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings13/340-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.lexjansen.com/pharmasug/2007/tt/TT09.pdf" target="_blank"&gt;https://www.lexjansen.com/pharmasug/2007/tt/TT09.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2013/07/31/gmail-from-sas-program/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2013/07/31/gmail-from-sas-program/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings10/060-2010.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings10/060-2010.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;/P&gt;&lt;P&gt;WIzarDE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 18 Feb 2018 17:24:28 GMT</pubDate>
    <dc:creator>WIzarDE</dc:creator>
    <dc:date>2018-02-18T17:24:28Z</dc:date>
    <item>
      <title>Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/438279#M28313</link>
      <description>&lt;P&gt;Hi there, this is my first time posting a question online I usually stick to lurking and finding similar queries to my own but alas I am having a world of difficulty setting the email configurations up in SAS EG so that I&amp;nbsp;can get&amp;nbsp;the program up and Running.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thank you all for all the help you provide the community I've found a ton of info already thanks to you all.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;My goal is to have&amp;nbsp;an automated program that is&amp;nbsp;scheduled for&amp;nbsp;a user,&amp;nbsp;upon being started it will&amp;nbsp;conclude a set of predetermined tasks&amp;nbsp;and email the user that made the request the results of the task.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Now I have everything ready but the last piece of the puzzle is the email part.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cannot use the&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;send to -&amp;gt; Email Recipient as a Step in Project&lt;/STRONG&gt;&amp;nbsp;&lt;/EM&gt;because as far as I can tell I can't give it a dynamic variable for it to use as the email recipient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select c_email
		into :email
		from USER_INFO
		;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I create the email variable with the above code and then wish to use it for sending the the email to the recipient &amp;amp;email.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now my companies email is a outlook base email from the office 365 schema.&lt;/P&gt;&lt;P&gt;So I though using the MAPI solution would be enough for me and it works fine when I run the task straight from SAS EG.&lt;BR /&gt;But when the program is invoked as a scheduled task from a user request it does not run the email program. But it doesn't specify the error either. It just has a cross mark on the program.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options
emailsys="MAPI"
EMAILID="xxx.yyy@company.com"
EMAILAUTHPROTOCOL=none
;

FILENAME Mailbox EMAIL 'xxx.yyy@company.com'
Subject='STARTUP';
DATA _NULL_;
FILE Mailbox;
PUT "Hello";
PUT "This is a test message from the DATA step";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 63px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18666i25F03DCD92F95FFD/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&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;So I've tested a few solutions SMTP connection with my GMAIL account for testing, MAPI with the companies Outlook client and using the E-mail Recipient step.&lt;BR /&gt;The gmail connection through SMTP works fine run directly from the task and invoked as a scheduled request from a user:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options
emailsys="smtp"
EMAILHOST="smtp.gmail.com"
EMAILPORT=25
EMAILID="xxx.yyy@gmail.com"
EMAILAUTHPROTOCOL=plain
EMAILPW="{SAS002}xxxx"
;

options emailhost=
 (
   "smtp.gmail.com" 
   /* alternate: port=487 SSL */
   port=587 STARTTLS 
   auth=plain 
   /* your Gmail address */
   id="xxx.yyy@gmail.com"
   /* optional: encode PW with PROC PWENCODE */
   pw="{SAS002}xxxx" 
 )
;
 
filename myemail EMAIL
  to=("&amp;amp;mail")
  subject="abc - Request from &amp;amp;user"
  attach	=	'C:\Desktop\abc.csv';
 
data _null_;
  file myemail;
  put "Dear User,";
  put "The request information is annexed in the current email";
  put "Best Regards,";
  put "xxx";
run;
 
filename myemail clear;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now this is where I am stuck right now because from what I can the the E-mail Recipient also use a SMTP connection but I cannot replicate it by script. It also uses Windows authentication.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 105px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18667i12C868EF4BA136F6/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 531px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/18668i1EF1DE3EC6CD2315/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So now how do I replicate the connection that this module is using by script?&lt;BR /&gt;&lt;BR /&gt;I tried the following, but I get an&amp;nbsp;ERROR: Email: The connection was refused.&lt;BR /&gt;The code I tried was as follow and I tried to mimic the gmail script:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options
emailsys="smtp"
EMAILHOST="mail.company.com"
EMAILPORT=25
EMAILID="xxx.yyy@company.com"
EMAILAUTHPROTOCOL=plain
EMAILPW="{SAS002}xxxx"
;

options emailhost=
 (
   "mail.company.com" 
   /* alternate: port=487 SSL */
   port=587 STARTTLS 
   auth=plain 
   id="xxx.yyy@company.com"
   /* optional: encode PW with PROC PWENCODE */
   pw="{SAS002}xxxx" 
 )
;

FILENAME Mailbox EMAIL 'xxx.yyy@company.com'
 Subject='STARTUP';
DATA _NULL_;
FILE Mailbox;
PUT "Hello";
PUT "This is a test message from the DATA step";
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with auth =&amp;nbsp;none I get&amp;nbsp;ERROR: Email: 530 5.7.1 Client was not authenticated.&lt;BR /&gt;And I know that this probably means that I cannot use an SSL&amp;nbsp; to TLS request. But I just can't&amp;nbsp;understand how to use the Windows Integrated authentication for the SMTP request the same that the E-mail Recipient does ...&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Any help on understanding why using MAPI isn't working as a scheduled taks or why I can use my account with a SMTP request from the E-MAIL Recipient task but can't replicate it by code on a data step would be apreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Some of my reading material can be found here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings13/023-2013.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings13/023-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings13/340-2013.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings13/340-2013.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.lexjansen.com/pharmasug/2007/tt/TT09.pdf" target="_blank"&gt;https://www.lexjansen.com/pharmasug/2007/tt/TT09.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2013/07/31/gmail-from-sas-program/" target="_blank"&gt;https://blogs.sas.com/content/sasdummy/2013/07/31/gmail-from-sas-program/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/resources/papers/proceedings10/060-2010.pdf" target="_blank"&gt;http://support.sas.com/resources/papers/proceedings10/060-2010.pdf&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;/P&gt;&lt;P&gt;WIzarDE&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Feb 2018 17:24:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/438279#M28313</guid>
      <dc:creator>WIzarDE</dc:creator>
      <dc:date>2018-02-18T17:24:28Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/438632#M28330</link>
      <description>&lt;P&gt;here's what I do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, I have this macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro email(email=,cc=,subject=,message=,attach=);&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;filename mymail email "&amp;amp;email"; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;data _null_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;file mymail&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;to=("&amp;amp;email")&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;%if %length(&amp;amp;cc)&amp;gt;0 %then %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cc=(&amp;amp;cc)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;%end;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;%if %length(&amp;amp;attach)&amp;gt;0 %then %do;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;attach=(&amp;amp;attach)&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;%end;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;subject="&amp;amp;subject.";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;put "&amp;amp;message.";&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;run;&lt;BR /&gt;&lt;BR /&gt;%mend;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I invoke it like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let endtime&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = %sysfunc(time(),time8.0)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ;&lt;BR /&gt;&lt;BR /&gt;%let pgmpath = %sysfunc(pathname(output));&lt;BR /&gt;%let currprog = &amp;amp;_CLIENTPROJECTNAME;&lt;BR /&gt;%email(email=&amp;amp;EMAILADDRESS&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;,subject=&amp;amp;currprog&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;,cc='person1@domain.com' 'person2@domain.com'&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;,message=has finished. started at &amp;amp;starttime and ended at &amp;amp;endtime&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;,attach="&amp;amp;pgmpath./file1.pdf" &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; "&amp;amp;pgmpath./file2.html" &lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; "&amp;amp;pgmpath./file3.rtf"&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So if you populated the cc list and put single quotes around each value you should be good to go.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Feb 2018 13:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/438632#M28330</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-02-20T13:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/439268#M28382</link>
      <description>&lt;P&gt;Hi, thanks for sharing. I think I will adapt your methodology I like how you have programmed it.&lt;BR /&gt;&lt;BR /&gt;But this doesn't seem to solve my problem of configuration so I can send emails in the same way the E-mail recipient step does.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 13:39:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/439268#M28382</guid>
      <dc:creator>WIzarDE</dc:creator>
      <dc:date>2018-02-22T13:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/439436#M28389</link>
      <description>&lt;P&gt;You could loop thru your list or just put the dynamic mailing list into the cc or email variable.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Feb 2018 20:07:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/439436#M28389</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-02-22T20:07:59Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/439643#M28402</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;But my problem is that the Email Recipient step doesn't accept variables. I can't put something like this in the "to" part:&lt;BR /&gt;%let email = 'jon.snow@north.com'&lt;BR /&gt;to: &amp;amp;email&lt;BR /&gt;&lt;BR /&gt;It doesn't recognise the variable.&lt;BR /&gt;&lt;BR /&gt;And if I write a code similar to yours I get an erro like this E-mail: Permission denied.&lt;BR /&gt;&lt;BR /&gt;My problem here is how do I replicate the SMTP configuration that the email step is using that was configured in the tools &amp;gt; options &amp;gt; administration. And uses Windows Integrated Authentification.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;WIzarDE&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 10:26:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/439643#M28402</guid>
      <dc:creator>WIzarDE</dc:creator>
      <dc:date>2018-02-23T10:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/439704#M28407</link>
      <description>&lt;P&gt;Okay.&amp;nbsp; It works for me.&amp;nbsp; I've been able to email with variables, as my macro shows.&amp;nbsp; Is anyone at your company able to email from within SAS?&amp;nbsp; If not, it sounds like a config/system problem.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2018 14:14:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/439704#M28407</guid>
      <dc:creator>tomrvincent</dc:creator>
      <dc:date>2018-02-23T14:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/444709#M28759</link>
      <description>&lt;P&gt;I don't have an Office 365 account to test this, but it looks like the configuration is similar to that for Gmail.&amp;nbsp; Sub in the Office 365 SMTP address as the host.&amp;nbsp; Here's a &lt;A href="https://support.office.com/en-us/article/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-office-365-69f58e99-c550-4274-ad18-c805d654b4c4?ui=en-US&amp;amp;rs=en-US&amp;amp;ad=US#option1" target="_self"&gt;Microsoft KB article with the settings&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options emailsys=SMTP;
options emailhost=
 (
   "smtp.office365.com" 
   port=587 STARTTLS 
   auth=login
   /* your Office 365 account/address */
   id="yourO365email@yourcompany.com"
   /* optional: encode PW with PROC PWENCODE */
   pw="your_password" 
 )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note the restrictions from the article: you must be able to supply your user/password -- no provision for a single-signon method, the way you might be accustomed to via a web browser.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding a dynamic TO list.&amp;nbsp; I do this in my jobs by placing the e-mail addresses in an external file (call it &lt;STRONG&gt;distlist.csv&lt;/STRONG&gt;, for example).&amp;nbsp; It's a simple text file with e-mail addresses stored, one per line.&amp;nbsp; Then I read it in like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename dl "/u/myaccount/distlist.csv";
data distlist;
  infile dl dsd;
  length email $ 50;
  input email;
run;

proc sql noprint;
select cat('"',trim(email),'"') into :toList separated by ' ' from distlist;
quit;

FILENAME OUTPUT EMAIL
                SUBJECT = "My Subject"
                FROM = "Chris Hemedinger &amp;lt;myemail@mycompany.com&amp;gt;"
                TO = (&amp;amp;toList)
		 type='text/html'
                CT ='text/html';

ods html(id=email)
  file=OUTPUT(title="My email report")
  style=seaside;

ods escapechar="^";
ods html(id=email) text="This automated report blah blah ^{newline 1} More info, and more info ^{newline 1}";

proc print data=mydata;
run;

ods html(id=email) close;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Mar 2018 13:36:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/444709#M28759</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-03-12T13:36:17Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/444755#M28765</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply Chris, the thing is when I use the same configuration as GMAIL I get the following error:&amp;nbsp;ERROR: Email: The connection has timed out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And what I find odd is that the email recipient block sends SMTP emails without a problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;WIzarDE&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 14:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/444755#M28765</guid>
      <dc:creator>WIzarDE</dc:creator>
      <dc:date>2018-03-12T14:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/444805#M28767</link>
      <description>&lt;P&gt;Hi again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems like I replied to early last time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks to your help I figured out what I was doing wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I was using what I have configured in the tools -&amp;gt; options -&amp;gt; administration for my SMTP server:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 523px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/19137i4509C97DD918D3F7/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which&amp;nbsp;for some reason is&amp;nbsp;different from the&amp;nbsp;smtp.office365.com server that you indicated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now if I use the code as you gave me directly I get this erro:&amp;nbsp;WARNING: Email: 550 5.7.60 SMTP; Client does not have permissions to send as this sender [DB6PR0602MB2901.eurprd06.prod.outlook.com]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the fix is quite simple, I just needed to add two lines in the options setup and keep the rest the same:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options emailsys=SMTP
EMAILPORT=25
EMAILID="yourO365email@yourcompany.com";
options emailhost=
 (
   "smtp.office365.com" 
   port=587 STARTTLS 
   auth=login
   /* your Office 365 account/address */
   id="yourO365email@yourcompany.com"
   /* optional: encode PW with PROC PWENCODE */
   pw="your_password" 
 )
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help and for your time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards,&lt;BR /&gt;Yasin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Mar 2018 15:43:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/444805#M28767</guid>
      <dc:creator>WIzarDE</dc:creator>
      <dc:date>2018-03-12T15:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/459312#M29588</link>
      <description>&lt;P&gt;Hi again,&lt;BR /&gt;&lt;BR /&gt;Sorry to bother you again Chris, but for some reason after weeks of working correctly my email step stopped working with the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Email: The connection has timed out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I haven't changed any options, and my password is still valid.&lt;BR /&gt;Do you know what the problem might be?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;BR /&gt;W&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2018 13:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/459312#M29588</guid>
      <dc:creator>WIzarDE</dc:creator>
      <dc:date>2018-05-02T13:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Email from a data step with dynamic mailing list</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/468331#M30383</link>
      <description>Good one .Helpful in my context as well.Thanks</description>
      <pubDate>Thu, 07 Jun 2018 12:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Email-from-a-data-step-with-dynamic-mailing-list/m-p/468331#M30383</guid>
      <dc:creator>NeerajS1104</dc:creator>
      <dc:date>2018-06-07T12:05:24Z</dc:date>
    </item>
  </channel>
</rss>

