<?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: send email from sas and attach file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930806#M366208</link>
    <description>&lt;P&gt;I think part of the issue is not referencing the correct Fileref&lt;/P&gt;
&lt;PRE&gt;29         FILENAME &lt;FONT size="5" color="#008000"&gt;&lt;STRONG&gt;myemail&lt;/STRONG&gt;&lt;/FONT&gt; EMAIL
30         TO="Ron.Einstein@BankLeumi.co.il"
31         FROM="Ron.Einstein@BankLeumi.co.il"
32         SUBJECT="Ron Report"
33         CONTENT_TYPE="text/html"
34         encoding="utf-8"
35         /*attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars.xlsx" content_type="excel")*/
36         ;
37         ODS LISTING CLOSE;
38         ODS HTML BODY=&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;mail&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;The error tells you the fileref Mail is not assigned, so no Html output is generated and I suspect means there isn't anything in the email actually attaching.&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jun 2024 13:53:30 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-06-04T13:53:30Z</dc:date>
    <item>
      <title>send email from sas and attach file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930768#M366182</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I run this code to send and email from SAS .&lt;/P&gt;
&lt;P&gt;The email should contain few sentences in body mail and summary tables in body mail.&lt;/P&gt;
&lt;P&gt;The email should also have attached XLSX&amp;nbsp; &amp;nbsp; file (sashelp.cars ).&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;What is the reason that this code don't produce the attach file to the email???&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc export data=sashelp.cars   
outfile="/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars.xlsx"
dbms=xlsx replace;
sheet="bakara_Yomit_Files";
Run;
 

title;
footnote;
FILENAME myemail EMAIL  
TO="Dave@gmail.com"
FROM="Dave@gmail.com"
SUBJECT="Ron Report" 
CONTENT_TYPE="text/html" 
encoding="utf-8"
attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars.xlsx" content_type="excel");
ODS LISTING CLOSE;
ODS HTML BODY=mail;
proc odstext;
heading 'Cars Report' /Style=Header {fontsize=16pt  color=blue  fontstyle=italic};
p 'Hello';
p 'Here is cars report';
p " ";
p "regards";
p "Dave";
run;
title;
footnote;
Title 'Cars';
proc report data = SasHelp.Cars(obs = 5) split = "*";
column Type MPG_Ratio MPG_City MPG_Highway;
define Type / display ;
define MPG_City / display;
define MPG_Highway / display;
define MPG_Ratio / computed 'City/Highway' format = 4.2;
compute MPG_Highway;  
MPG_Ratio = MPG_City/MPG_Highway;
endcomp;
run;
title;
footnote;
Title 'class';
proc report data = SasHelp.class(obs = 5);
run;
ODS HTML CLOSE;
ODS LISTING;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jun 2024 07:20:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930768#M366182</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-06-04T07:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: send email from sas and attach file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930769#M366183</link>
      <description>&lt;P&gt;Show us the log for the part of your code that you think is supposed to attach the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 07:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930769#M366183</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-04T07:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: send email from sas and attach file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930770#M366184</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc export data=sashelp.cars   
outfile="/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars.xlsx"
dbms=xlsx replace;
sheet="bakara_Yomit_Files";
Run;
 

title;
footnote;
FILENAME myemail EMAIL  
TO="Ron.Einstein@BankLeumi.co.il"
FROM="Ron.Einstein@BankLeumi.co.il"
SUBJECT="Ron Report" 
CONTENT_TYPE="text/html" 
encoding="utf-8"
attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars.xlsx" content_type="excel");
ODS LISTING CLOSE;
ODS HTML BODY=mail;
proc odstext;
heading 'Cars Report' /Style=Header {fontsize=16pt  color=blue  fontstyle=italic};
p 'Hello';
p 'Here is cars report';
p " ";
p "regards";
p "Dave";
run;
title;
footnote;
Title 'Cars';
proc report data = SasHelp.Cars(obs = 5) split = "*";
column Type MPG_Ratio MPG_City MPG_Highway;
define Type / display ;
define MPG_City / display;
define MPG_Highway / display;
define MPG_Ratio / computed 'City/Highway' format = 4.2;
compute MPG_Highway;  
MPG_Ratio = MPG_City/MPG_Highway;
endcomp;
run;
title;
footnote;
Title 'class';
proc report data = SasHelp.class(obs = 5);
run;
ODS HTML CLOSE;
ODS LISTING;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Error in Log&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;1                                                          The SAS System                                10:54 Tuesday, June 4, 2024

1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Program';
4          %LET _CLIENTPROCESSFLOWNAME='Process Flow';
5          %LET _CLIENTPROJECTPATH='';
6          %LET _CLIENTPROJECTPATHHOST='';
7          %LET _CLIENTPROJECTNAME='';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=PNG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         FILENAME EGSR TEMP;
15         ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
16             STYLE=HTMLBlue
17             STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HTMLBlue.css")
18             NOGTITLE
19             NOGFOOTNOTE
20             GPATH=&amp;amp;sasworklocation
21             ENCODING=UTF8
22             options(rolap="on")
23         ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
24         
25         GOPTIONS ACCESSIBLE;
26         
27         title;
28         footnote;
29         FILENAME myemail EMAIL
30         TO="Ron.Einstein@BankLeumi.co.il"
31         FROM="Ron.Einstein@BankLeumi.co.il"
32         SUBJECT="Ron Report"
33         CONTENT_TYPE="text/html"
34         encoding="utf-8"
35         /*attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars.xlsx" content_type="excel")*/
36         ;
37         ODS LISTING CLOSE;
38         ODS HTML BODY=mail;
NOTE: Writing HTML Body file: MAIL
ERROR: No logical assign for filename MAIL.
ERROR: No body file. HTML output will not be created.
39         proc odstext;
40         heading 'Cars Report' /Style=Header {fontsize=16pt  color=blue  fontstyle=italic};
41         p 'Hello';
42         p 'Here is cars report';
43         p " ";
44         p "regards";
45         p "Dave";
46         run;
NOTE: PROCEDURE ODSTEXT used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
      memory              71.90k
      OS Memory           24480.00k
      Timestamp           06/04/2024 10:57:15 AM
      Step Count                        13  Switch Count  0
2                                                          The SAS System                                10:54 Tuesday, June 4, 2024

      Page Faults                       0
      Page Reclaims                     9
      Page Swaps                        0
      Voluntary Context Switches        3
      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      

47         title;
48         footnote;
49         Title 'Cars';
50         proc report data = SasHelp.Cars(obs = 5) split = "*";
51         column Type MPG_Ratio MPG_City MPG_Highway;
52         define Type / display ;
53         define MPG_City / display;
54         define MPG_Highway / display;
55         define MPG_Ratio / computed 'City/Highway' format = 4.2;
56         compute MPG_Highway;
57         MPG_Ratio = MPG_City/MPG_Highway;
58         endcomp;
59         run;

NOTE: Multiple concurrent threads will be used to summarize data.
NOTE: There were 5 observations read from the data set SASHELP.CARS.
NOTE: PROCEDURE REPORT used (Total process time):
      real time           0.01 seconds
      user cpu time       0.01 seconds
      system cpu time     0.00 seconds
      memory              8438.12k
      OS Memory           31668.00k
      Timestamp           06/04/2024 10:57:15 AM
      Step Count                        14  Switch Count  0
      Page Faults                       0
      Page Reclaims                     1754
      Page Swaps                        0
      Voluntary Context Switches        30
      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      

60         title;
61         footnote;
62         Title 'class';
63         proc report data = SasHelp.class(obs = 5);
64         run;

NOTE: Multiple concurrent threads will be used to summarize data.
NOTE: There were 5 observations read from the data set SASHELP.CLASS.
NOTE: PROCEDURE REPORT used (Total process time):
      real time           0.00 seconds
      user cpu time       0.00 seconds
      system cpu time     0.01 seconds
      memory              7685.28k
      OS Memory           30644.00k
      Timestamp           06/04/2024 10:57:16 AM
      Step Count                        15  Switch Count  0
3                                                          The SAS System                                10:54 Tuesday, June 4, 2024

      Page Faults                       0
      Page Reclaims                     1442
      Page Swaps                        0
      Voluntary Context Switches        22
      Involuntary Context Switches      0
      Block Input Operations            0
      Block Output Operations           0
      

65         ODS HTML CLOSE;
66         ODS LISTING;
67         
68         GOPTIONS NOACCESSIBLE;
69         %LET _CLIENTTASKLABEL=;
70         %LET _CLIENTPROCESSFLOWNAME=;
71         %LET _CLIENTPROJECTPATH=;
72         %LET _CLIENTPROJECTPATHHOST=;
73         %LET _CLIENTPROJECTNAME=;
74         %LET _SASPROGRAMFILE=;
75         %LET _SASPROGRAMFILEHOST=;
76         
77         ;*';*";*/;quit;run;
78         ODS _ALL_ CLOSE;
79         
80         
81         QUIT; RUN;
82         
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Jun 2024 07:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930770#M366184</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2024-06-04T07:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: send email from sas and attach file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930806#M366208</link>
      <description>&lt;P&gt;I think part of the issue is not referencing the correct Fileref&lt;/P&gt;
&lt;PRE&gt;29         FILENAME &lt;FONT size="5" color="#008000"&gt;&lt;STRONG&gt;myemail&lt;/STRONG&gt;&lt;/FONT&gt; EMAIL
30         TO="Ron.Einstein@BankLeumi.co.il"
31         FROM="Ron.Einstein@BankLeumi.co.il"
32         SUBJECT="Ron Report"
33         CONTENT_TYPE="text/html"
34         encoding="utf-8"
35         /*attach=("/usr/local/SAS/SASUsers/LabRet/UserDir/udclk79/cars.xlsx" content_type="excel")*/
36         ;
37         ODS LISTING CLOSE;
38         ODS HTML BODY=&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;mail&lt;/STRONG&gt;&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;The error tells you the fileref Mail is not assigned, so no Html output is generated and I suspect means there isn't anything in the email actually attaching.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 13:53:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930806#M366208</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-06-04T13:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: send email from sas and attach file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930823#M366213</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods excel file = "~/test.xlsx";
	proc print data=sashelp.cars;
	run;
ods excel close;


proc copy in=sashelp out=work;
	select cars;
run;


FILENAME mail EMAIL 
TO=("xxx@email.com")
FROM=("xxxx@email.com")
SUBJECT="Cars"
encoding='utf-8'
CONTENT_TYPE="text/html"
encoding="utf-8"
attach=(
"%sysfunc(pathname(work))/cars.sas7bdat" 
content_type="application/SAS7BDAT" "~/test.xlsx" content_type="excel"
)
;

data _null_;
	file mail;
	Put "Testing";
	Put "Testing";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Can you try this?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jun 2024 15:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/send-email-from-sas-and-attach-file/m-p/930823#M366213</guid>
      <dc:creator>Mazi</dc:creator>
      <dc:date>2024-06-04T15:11:37Z</dc:date>
    </item>
  </channel>
</rss>

