Usage Note 59389: Attaching and emailing Excel files using a FILENAME statement with the EMAIL access method might generate unreadable files
When you email native Excel files from SAS as an attachment using the EMAIL access method in a FILENAME statement, an error like the following might be generated when the files are opened:

The error occurs when the mail server does not know which application to associate with the attachment. These files might be created using the ODS destination for Excel or PROC EXPORT.
If the Excel file has a .xlsx extension, the CONTENT_TYPE= option within the ATTACH= option might be needed in the FILENAME statement to associate the correct mime-type for the Office Open XML format (.xlsx). Click the Full Code tab to see an example of applying the correct mime-type for the attachment.
Operating System and Release Information
| SAS System | Base SAS | 64-bit Enabled Solaris | 9.4 TS1M3 | |
| 64-bit Enabled AIX | 9.4 TS1M3 | |
| Windows 7 Ultimate x64 | 9.4 TS1M3 | |
| Windows 7 Ultimate 32 bit | 9.4 TS1M3 | |
| Windows 7 Professional x64 | 9.4 TS1M3 | |
| Windows 7 Professional 32 bit | 9.4 TS1M3 | |
| Windows 7 Home Premium x64 | 9.4 TS1M3 | |
| Windows 7 Home Premium 32 bit | 9.4 TS1M3 | |
| Windows 7 Enterprise x64 | 9.4 TS1M3 | |
| Windows 7 Enterprise 32 bit | 9.4 TS1M3 | |
| Microsoft Windows Server 2012 Std | 9.4 TS1M3 | |
| Microsoft Windows Server 2012 R2 Std | 9.4 TS1M3 | |
| Microsoft Windows Server 2012 R2 Datacenter | 9.4 TS1M3 | |
| Microsoft Windows Server 2012 Datacenter | 9.4 TS1M3 | |
| Microsoft Windows Server 2008 for x64 | 9.4 TS1M3 | |
| Microsoft Windows Server 2008 R2 | 9.4 TS1M3 | |
| Microsoft Windows Server 2008 | 9.4 TS1M3 | |
| Microsoft Windows 10 | 9.4 TS1M3 | |
| Microsoft Windows 8.1 Pro x64 | 9.4 TS1M3 | |
| Microsoft Windows 8.1 Pro 32-bit | 9.4 TS1M3 | |
| Microsoft Windows 8.1 Enterprise x64 | 9.4 TS1M3 | |
| Microsoft Windows 8.1 Enterprise 32-bit | 9.4 TS1M3 | |
| Microsoft Windows 8 Pro x64 | 9.4 TS1M3 | |
| Microsoft Windows 8 Pro 32-bit | 9.4 TS1M3 | |
| Microsoft Windows 8 Enterprise x64 | 9.4 TS1M3 | |
| Microsoft Windows 8 Enterprise 32-bit | 9.4 TS1M3 | |
| Microsoft® Windows® for x64 | 9.4 TS1M3 | |
| z/OS 64-bit | 9.4 TS1M3 | |
| z/OS | 9.4 TS1M3 | |
| Solaris for x64 | 9.4 TS1M3 | |
| Linux for x64 | 9.4 TS1M3 | |
| HP-UX IPF | 9.4 TS1M3 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
ods excel file='c:\temp\test.xlsx';
proc print data=sashelp.cars;
run;
ods excel close;
filename mailit email
to='joebloe@yahoo.com'
subject="ODS Excel Test"
attach=("c:\temp\test.xlsx" content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" lrecl=32000);
run;
data _null_;
file mailit;
put "ODS Excel Test";
run;
| Type: | Usage Note |
| Priority: | medium |
| Date Modified: | 2017-01-27 15:42:15 |
| Date Created: | 2016-11-21 09:38:22 |