<?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: How to send an email with report in body and Exel attachments? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-an-email-with-report-in-body-and-Exel-attachments/m-p/952900#M372387</link>
    <description>&lt;P&gt;This article is a good reference:&amp;nbsp;&lt;LI-MESSAGE title="How to send email using SAS" uid="746523" url="https://communities.sas.com/t5/SAS-Communities-Library/How-to-send-email-using-SAS/m-p/746523#U746523" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will combine two of the techniques: add an attachment and include ODS output in the body of the email. Here's a simple example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;options emailsys=smtp
 emailhost='yourmail.host.com';

%let outfile=c:\Projects\class.xlsx;
proc export
 data=sashelp.class
 file="&amp;amp;outfile"
 dbms=xlsx
 replace;
sheet="Class Roster";
run;

%let toList="recipient@destination.com";

FILENAME OUTPUT EMAIL
	SUBJECT = "Impressive Report"
	FROM = "Chris &amp;lt;chris.blogger@sas.com&amp;gt;"
	TO = (&amp;amp;toList)
	CT ='text/html'
  attach=("&amp;amp;outfile." 
  content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

ods tagsets.msoffice2k(id=email)
  file=OUTPUT(title="My report")
  style=htmlencore;

  /* The report body in the email */
title "Class Roster";
proc print data=sashelp.class;
run;

ods tagsets.msoffice2k(id=email) close;&lt;/LI-CODE&gt;</description>
    <pubDate>Sun, 08 Dec 2024 18:33:39 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2024-12-08T18:33:39Z</dc:date>
    <item>
      <title>How to send an email with report in body and Exel attachments?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-an-email-with-report-in-body-and-Exel-attachments/m-p/952898#M372386</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;My client wants emails sent with one report in the body of the email and attached Excel files. The files, because they are large, are just straight.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc export data=details outfile="&amp;amp;details" dbms=xlsx replace; sheet="Details Part1"; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The report they want embedded in the same report is a straight result from another dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can figure out how to attach or print within the email but not both. Any examples you can point me to?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 08 Dec 2024 16:26:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-an-email-with-report-in-body-and-Exel-attachments/m-p/952898#M372386</guid>
      <dc:creator>SASGeek</dc:creator>
      <dc:date>2024-12-08T16:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to send an email with report in body and Exel attachments?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-send-an-email-with-report-in-body-and-Exel-attachments/m-p/952900#M372387</link>
      <description>&lt;P&gt;This article is a good reference:&amp;nbsp;&lt;LI-MESSAGE title="How to send email using SAS" uid="746523" url="https://communities.sas.com/t5/SAS-Communities-Library/How-to-send-email-using-SAS/m-p/746523#U746523" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will combine two of the techniques: add an attachment and include ODS output in the body of the email. Here's a simple example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;options emailsys=smtp
 emailhost='yourmail.host.com';

%let outfile=c:\Projects\class.xlsx;
proc export
 data=sashelp.class
 file="&amp;amp;outfile"
 dbms=xlsx
 replace;
sheet="Class Roster";
run;

%let toList="recipient@destination.com";

FILENAME OUTPUT EMAIL
	SUBJECT = "Impressive Report"
	FROM = "Chris &amp;lt;chris.blogger@sas.com&amp;gt;"
	TO = (&amp;amp;toList)
	CT ='text/html'
  attach=("&amp;amp;outfile." 
  content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

ods tagsets.msoffice2k(id=email)
  file=OUTPUT(title="My report")
  style=htmlencore;

  /* The report body in the email */
title "Class Roster";
proc print data=sashelp.class;
run;

ods tagsets.msoffice2k(id=email) close;&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 08 Dec 2024 18:33:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-send-an-email-with-report-in-body-and-Exel-attachments/m-p/952900#M372387</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-12-08T18:33:39Z</dc:date>
    </item>
  </channel>
</rss>

