From: Tiffany on
Hello,

I am having some trouble emailing an xls attachment. I am sending an
email with the body in html with data output, but I also want to
attach an xls file in case people want to manipulate the data. The
xls file is being created fine, but when I attach it is gets appended
as a text file with a .xls extension and strange text in the file.
Any suggestions?

thanks you!
Tiffany

my code:

%MACRO REPORTS;

%if &records %then %do;
ods listing close;

title "Weekly Report";
ODS TAGSETS.EXCELXP
file='/home/mydocs/coverage.xls' options(width_fudge='0.75')
STYLE=Printer
OPTIONS ( Orientation = 'landscape'
FitToPage = 'yes'
Pages_FitWidth = '1'
Pages_FitHeight = '100'
embedded_titles = 'yes');

proc print data=coverage noobs;
run;

ods tagsets.excelxp close;
ods listing;

filename outfile email
to ='me(a)something.com'
replyto='me(a)something.com'
subject= "Weekly Report"
attach= ("/home/mydocs/coverage.xls")
type="text/html";


ods html body = outfile style=sasweb2;

proc print data = coverage;
run;

ods html close;

data _null_;
file temp;
run;

%end;
%mend reports;
%reports;


* example of text in attached file:
<?xml version="1.0" ?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"...
From: Chris Jones on
On 27 May, 19:32, Tiffany <tiffany.vi...(a)gmail.com> wrote:
> Hello,
>
> I am having some trouble emailing an xls attachment.  I am sending an
> email with the body in html with data output, but I also want to
> attach an xls file in case people want to manipulate the data.  The
> xls file is being created fine, but when I attach it is gets appended
> as a text file with a .xls extension and strange text in the file.
> Any suggestions?
>
> thanks you!
> Tiffany
>
> my code:
>
> %MACRO REPORTS;
>
> %if &records %then %do;
> ods listing close;
>
> title "Weekly Report";
> ODS TAGSETS.EXCELXP
> file='/home/mydocs/coverage.xls' options(width_fudge='0.75')
> STYLE=Printer
> OPTIONS ( Orientation = 'landscape'
> FitToPage = 'yes'
> Pages_FitWidth = '1'
> Pages_FitHeight = '100'
> embedded_titles = 'yes');
>
> proc print data=coverage noobs;
> run;
>
> ods tagsets.excelxp close;
> ods listing;
>
> filename outfile email
>         to =...@something.com'
>         replyto=...(a)something.com'
>         subject= "Weekly Report"
>                 attach= ("/home/mydocs/coverage.xls")
>                 type="text/html";
>
> ods html body = outfile style=sasweb2;
>
> proc print data = coverage;
> run;
>
> ods html close;
>
> data _null_;
> file temp;
> run;
>
> %end;
> %mend reports;
> %reports;
>
> * example of text in attached file:
> <?xml version="1.0" ?>
> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
>           xmlns:x="urn:schemas-microsoft-com:office:excel"
>           xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"...

Hi

Create the output .xls file using

ods html body="/home/mydocs/coverage.xls"....
proc report ; run ;
ods html close

then attach this file to your email

filename outfile email
to =...@something.com'
replyto=...(a)something.com'
subject= "Weekly Report"
attach= ("/home/mydocs/coverage.xls")
type="text/html";

data _null_ ;
file outfile ;
run ;
filename outfile clear;