A file that is saved to SAS® Content cannot be attached to an email with the EMAIL (SMTP) access method


An attempt to attach a file that resides in SAS Content by using the ATTACH= option with the EMAIL (SMTP) access method is not successful. Instead, you see the following messages:

ERROR: Error opening attachment file /directory/filename.extension.
ERROR: Physical file does not exist, /directory/filename.extension.

The ATTACH= option in the FILENAME EMAIL statement is expecting to access the file from a physical location. For more information about how to use this option, see FILENAME Statement: EMAIL (SMTP) Access Method.

Note: Information that is in SAS Content is not stored on the file system as a physical file. A recent blog post, Where are my SAS Viya files?, describes how files are accessed by SAS® Viya®.

A workaround is to write a temporary copy of the file that you want to attach to the file system and then use that file for the ATTACH= option. The following syntax is an example:

filename in filesrvc folderpath="/directory/subdirectory/" filename='filename.extension';
filename out "/tmp/filename.extension";

%let x=%sysfunc(fcopy(in,out));

filename myemail email to="person@company.com"

attach=("/tmp/filename.extension" content_type="content-type") subject="subject-text";