Hi, Sorry to all for dropping off this chain. The solution I got from SAS is below. It is adaptable to any file type (again, I think this is for SAS EG only, I never had such complications with base SAS), can send different numbers of files to different recipients, can be sent to any number of recipients, and can be sent automatically through code without needing to go through the EG program builder or whatever it's called. I never got comfortable with it so I don't use it. You can drop any mimetypes that you don't need (I have only used PDF, CSV, XLSX, and DOCX, for example). %macro emaildata (to_address, attachments);
proc format;
value $mimetypes
'csv' = 'text/csv'
'doc' = 'application/msword'
'docx' = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
'html' = 'text/html'
'jpeg' = 'image/jpeg'
'pdf' = 'application/pdf'
'ppt' = 'application/vnd.ms-powerpointtd'
'pptx' = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'
'xls' = 'application/vnd.ms-excel'
'xlsx' = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
'xml' = 'application/xml'
'zip' = 'application/zip, application/x-compressed-zip'
;
run;
%local newAttach;
%do i = 1 %to 100 %by 2;
%let workingFile = %scan(&attachments,&i,%str(%'%"));
%put WorkingFile=&workingFile;
%if %bquote(&workingFile) ne %then
%do;
%put WorkingFile=&workingFile;
%let extension = %scan(&workingFile,-1,.);
%if %bquote(%sysfunc(putc(&extension,$mimetypes.))) ne Invalid %then
%let newAttach = &newAttach "&workingfile" content_type="%sysfunc(putc(&extension,$mimetypes.))";
%put newAttach = &newAttach;
%end;
%end;
Filename output email;
data _null_;
file output
to = (&to_address)
subject = "[secure] Subject"
attach = (&newAttach lrecl=32000);
put "Text";
run;
%mend emaildata;
/* Test */
%emaildata ('recipient@domain',
"file1.xlsx"
"file2.csv"
"file3.docx");
... View more