<?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 Re: Sending automated email from SAS with attachments that changes name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sending-automated-email-from-SAS-with-attachments-that-changes/m-p/705702#M216530</link>
    <description>&lt;P&gt;Use a macro variable to designate the attachment file when you create it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create the attachment file in the WORK library so it will be automatically deleted when the SAS session ends */
%let myFile=%sysfunc(pathname(work))\Report.pdf;&lt;BR /&gt;ods pdf body="&amp;amp;myFile" style=Journal;
   PROC SQL;
   title "Details from sashelp.class where age &amp;gt; 10";
   SELECT * from sashelp.class where age &amp;gt; 10;
   quit;
ods pdf close;

  /* Set up this email using the PDF created above as an attachment*/
filename mymail email "my.recipient@example.com" 
             subject="Report for sashelp.class" 
              lrecl=256 type="TEXT/HTML"
            /* Attachment information */ 
            attach="&amp;amp;myFile";
ods html5 body=mymail style=sasweb;
options nocenter;
title;
/* Write the body of the email */
data _null_;
   file print;
   put "Here is the information you asked for.";
   put "May the SAS be with you!";
   put "Mark";
run;
ods html5 close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Dec 2020 14:20:45 GMT</pubDate>
    <dc:creator>SASJedi</dc:creator>
    <dc:date>2020-12-14T14:20:45Z</dc:date>
    <item>
      <title>Sending automated email from SAS with attachments that changes name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-automated-email-from-SAS-with-attachments-that-changes/m-p/705650#M216524</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I have files that should be send out every week. These files changes names e.g. "filename_1" next week it will be "filename_2".&lt;/P&gt;&lt;P&gt;But it only takes the filename that I manually wrote which is filename_1. Is there a way to say that it should take the latest file with this name everyweek,instead of me doing it manually every week?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is my code for the email (I manually wrote the filename):&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;filename outbox email&lt;BR /&gt;from="test@test.dk"&lt;BR /&gt;to="test@test.dk"&lt;BR /&gt;type='text/html'&lt;BR /&gt;subject='test'&lt;BR /&gt;attach=("F:\filename_1.png" ct='png')&lt;BR /&gt;ods html body=outbox rs=none style=Htmlblue;run;&lt;BR /&gt;ods html close;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 12:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-automated-email-from-SAS-with-attachments-that-changes/m-p/705650#M216524</guid>
      <dc:creator>mmea</dc:creator>
      <dc:date>2020-12-14T12:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sending automated email from SAS with attachments that changes name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sending-automated-email-from-SAS-with-attachments-that-changes/m-p/705702#M216530</link>
      <description>&lt;P&gt;Use a macro variable to designate the attachment file when you create it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Create the attachment file in the WORK library so it will be automatically deleted when the SAS session ends */
%let myFile=%sysfunc(pathname(work))\Report.pdf;&lt;BR /&gt;ods pdf body="&amp;amp;myFile" style=Journal;
   PROC SQL;
   title "Details from sashelp.class where age &amp;gt; 10";
   SELECT * from sashelp.class where age &amp;gt; 10;
   quit;
ods pdf close;

  /* Set up this email using the PDF created above as an attachment*/
filename mymail email "my.recipient@example.com" 
             subject="Report for sashelp.class" 
              lrecl=256 type="TEXT/HTML"
            /* Attachment information */ 
            attach="&amp;amp;myFile";
ods html5 body=mymail style=sasweb;
options nocenter;
title;
/* Write the body of the email */
data _null_;
   file print;
   put "Here is the information you asked for.";
   put "May the SAS be with you!";
   put "Mark";
run;
ods html5 close;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2020 14:20:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sending-automated-email-from-SAS-with-attachments-that-changes/m-p/705702#M216530</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2020-12-14T14:20:45Z</dc:date>
    </item>
  </channel>
</rss>

