<?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: SAS Enterprise Guide Email Multiple Attachments in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/465547#M30131</link>
    <description>&lt;P&gt;* Each attachment must have a separate attach statement;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;file outbox&lt;/P&gt;&lt;P&gt;to=(&amp;amp;email_to)&lt;/P&gt;&lt;P&gt;cc=(&amp;amp;email_cc)&lt;/P&gt;&lt;P&gt;From=(&amp;amp;email_from)&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;subject=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"Subject here"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;attach=(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"file1.csv"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;attach=(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"file2.csv"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;put &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"*** My report *** "&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 May 2018 00:55:30 GMT</pubDate>
    <dc:creator>Julian_Visch</dc:creator>
    <dc:date>2018-05-29T00:55:30Z</dc:date>
    <item>
      <title>SAS Enterprise Guide Email Multiple Attachments</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/369235#M24146</link>
      <description>&lt;P&gt;My company has recently switched to SAS Enterprise Guide, and one of my responsibilities is to email out large batches of emails with multiple attachments. I know that to attach .xlsx files you need to add the line&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;content_type=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; lrecl=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;32000&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;to your attach= statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have verified that each individual attachment works but when I try to send all attachments at once, only the last one attached can be opened. Every other attachment is corrupted and can't be viewed. Any help would be appreciated, thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro emaildata (to_address, attachments);
 Filename output email;
 data _null_;
	file output
	to = (&amp;amp;to_address.)
	subject = "Subject Line"
	attach = (&amp;amp;attachments. content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" lrecl=32000);

 put "text."; 

run;
%mend emaildata;


/* Test */
%emaildata ('recipient', "&amp;amp;attach1." "&amp;amp;attach2." "&amp;amp;attach3." "&amp;amp;attach4." "&amp;amp;attach5." "&amp;amp;attach6.");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jun 2017 17:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/369235#M24146</guid>
      <dc:creator>ColeG</dc:creator>
      <dc:date>2017-06-21T17:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Enterprise Guide Email Multiple Attachments</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/369618#M24167</link>
      <description>&lt;P&gt;Cole,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't have an answer to using the macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes EGuide works better if you use its tools.&amp;nbsp; If you have a file to send, right click on it and select 'send to' and then 'email as a step in the project'.&amp;nbsp; Once you've added one file, you can add others.&amp;nbsp; It's pretty flexible about sending data and reports.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;{Added}.&amp;nbsp; You need to do some setup in tools--&amp;gt; options and the mail is sent from your pc, not from the server.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 18:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/369618#M24167</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2017-06-22T18:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Enterprise Guide Email Multiple Attachments</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/465547#M30131</link>
      <description>&lt;P&gt;* Each attachment must have a separate attach statement;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;file outbox&lt;/P&gt;&lt;P&gt;to=(&amp;amp;email_to)&lt;/P&gt;&lt;P&gt;cc=(&amp;amp;email_cc)&lt;/P&gt;&lt;P&gt;From=(&amp;amp;email_from)&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;subject=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"Subject here"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;attach=(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"file1.csv"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;attach=(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"file2.csv"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;put &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"*** My report *** "&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 00:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/465547#M30131</guid>
      <dc:creator>Julian_Visch</dc:creator>
      <dc:date>2018-05-29T00:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Enterprise Guide Email Multiple Attachments</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/465583#M30138</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212450"&gt;@Julian_Visch&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;* Each attachment must have a separate attach statement;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/212450"&gt;@Julian_Visch&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You can attach multiple documents via a single ATTACH statement as documented here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://go.documentation.sas.com/?docsetId=hostunx&amp;amp;docsetTarget=p1hl3t66coao7bn18vrmhx2gte1q.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank"&gt;http://go.documentation.sas.com/?docsetId=hostunx&amp;amp;docsetTarget=p1hl3t66coao7bn18vrmhx2gte1q.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="xis-term"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="xis-term"&gt;ATTACH='&lt;SPAN class="xis-userSuppliedValue"&gt;filename.ext&lt;/SPAN&gt;' | ATTACH= ('&lt;SPAN class="xis-userSuppliedValue"&gt;filename.ext&lt;/SPAN&gt;' &amp;lt;&lt;SPAN class="xis-userSuppliedValue"&gt;attachment-options&lt;/SPAN&gt;&amp;gt;)&lt;/DIV&gt;
&lt;DIV class="xis-definition"&gt;
&lt;DIV class="xis-paraSimpleFirst"&gt;specifies the physical names of the files to be attached to the message and any options to modify attachment specifications. Enclose &lt;SPAN class="xis-userSuppliedValue"&gt;filename.ext&lt;/SPAN&gt; in quotation marks. To attach more than one file, enclose the group of filenames in parentheses. For example, &lt;CODE class="xis-codeDefaultStyle"&gt;attach='/u/userid/opinion.txt'&lt;/CODE&gt; and &lt;CODE class="xis-codeDefaultStyle"&gt;attach=("june11.txt" "july11.txt")&lt;/CODE&gt; are valid file attachments.&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 03:06:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/465583#M30138</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-29T03:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Enterprise Guide Email Multiple Attachments</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/465584#M30139</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134244"&gt;@ColeG&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Not sure but could it be that if you can't use default attachment options that you need to repeat them after every single attachment?&lt;/P&gt;
&lt;P&gt;May be worth a test.&lt;/P&gt;</description>
      <pubDate>Tue, 29 May 2018 03:18:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/465584#M30139</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-05-29T03:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Enterprise Guide Email Multiple Attachments</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/537587#M33104</link>
      <description>&lt;P&gt;Hi There&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was looking into this also, however i believe that the code suggested would need to be modified to:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;file outbox&lt;/P&gt;&lt;P&gt;to=(&amp;amp;email_to)&lt;/P&gt;&lt;P&gt;cc=(&amp;amp;email_cc)&lt;/P&gt;&lt;P&gt;From=(&amp;amp;email_from)&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;subject=&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"Subject here"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;attach=(&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"file1.csv"&amp;nbsp;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"file2.csv"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;put&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3" color="#800080"&gt;"*** My report *** "&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;anyway the code i normally use in full is:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;FILENAME Mailbox&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;EMAIL 'user@domain.com.au'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;CC='user@domain2.com.au'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Subject='This is my report'&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;ATTACH=( 'path/file1.doc' 'path/file2.doc');&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;DATA _NULL_;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;FILE Mailbox;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;PUT "Email body text";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;PUT "More email text";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;RUN;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;Hope this helps &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 03:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/537587#M33104</guid>
      <dc:creator>SamuelD</dc:creator>
      <dc:date>2019-02-22T03:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Enterprise Guide Email Multiple Attachments</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/537801#M33115</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry to all for dropping off this chain. The solution I got from SAS is below. It is adaptable to any file type (again, I think this is for SAS EG only, I never had such complications with base SAS), can send different numbers of files to different recipients, can be sent to any number of recipients, and can be sent automatically through code without needing to go through the EG program builder or whatever it's called. I never got comfortable with it so I don't use it. You can drop any mimetypes that you don't need (I have only used PDF, CSV, XLSX, and DOCX, for example).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro emaildata (to_address, attachments);
proc format;
 value $mimetypes
         'csv'   = 'text/csv'
         'doc'   = 'application/msword'
         'docx'  = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
         'html'  = 'text/html'
         'jpeg'  = 'image/jpeg'
         'pdf'   = 'application/pdf'
         'ppt'   = 'application/vnd.ms-powerpointtd'
         'pptx'  = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
         'xls'   = 'application/vnd.ms-excel'
         'xlsx'  = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
         'xml'   = 'application/xml'
         'zip'   = 'application/zip, application/x-compressed-zip'
      ;
   run;
   %local newAttach;
   %do i = 1 %to 100 %by 2;
      %let workingFile = %scan(&amp;amp;attachments,&amp;amp;i,%str(%'%"));
      %put WorkingFile=&amp;amp;workingFile;

      %if %bquote(&amp;amp;workingFile) ne %then
         %do;
            %put WorkingFile=&amp;amp;workingFile;
            %let extension = %scan(&amp;amp;workingFile,-1,.);
            %if %bquote(%sysfunc(putc(&amp;amp;extension,$mimetypes.))) ne Invalid %then
               %let newAttach = &amp;amp;newAttach "&amp;amp;workingfile" content_type="%sysfunc(putc(&amp;amp;extension,$mimetypes.))";
            %put newAttach = &amp;amp;newAttach;
         %end;
   %end;

 Filename output email;
 data _null_;
 file output
 to = (&amp;amp;to_address)
 subject = "[secure] Subject"
 attach = (&amp;amp;newAttach lrecl=32000);

 put "Text";

run;

%mend emaildata;

/* Test */
%emaildata ('recipient@domain', 
"file1.xlsx"
"file2.csv"
"file3.docx");&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Feb 2019 18:30:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-Enterprise-Guide-Email-Multiple-Attachments/m-p/537801#M33115</guid>
      <dc:creator>ColeG</dc:creator>
      <dc:date>2019-02-22T18:30:02Z</dc:date>
    </item>
  </channel>
</rss>

