.pptx) using the ODS PowerPoint destination and properly closed it with:FILEEXIST=1).FCOPY successfully copies the PPTX to a local WORK directory (RC=0)..pptx files rather than a problem with the PowerPoint file itself..pptx attachments being truncated or corrupted when sent through the SAS Email engine? If so, were there any recommended workarounds or configuration changes?
@bijayadhikar wrote:
Sorry for typo. PPTX was not copied as text.
Why do you think that?
Try being specific in how you want SAS to read and write the files when copying.
filename src "&pptpath" recfm=f lrecl=512;
filename dst "&pptlocal" recfm=f lrecl=512;
Also make sure to tell the email process what type of file it is attaching, this will help the recipient know what application to use to open the file. It will also help with email filters.
filename mymail email
to = "my.email@com"
subject = "Monthly Performance Deck"
attach = ("&pptlocal" content_type="application/pptx")
;
You might try something like zipping the pptx file before emailing it, if you suspect it's getting corrupted by SAS or your mail server. Maybe that's a silly idea, since pptx is literally a zip file.
You could try changing the extension on the .pptx to something neutral like .txt in case your email system has blocker on sending .pptx files.
If you have IT support, you might want to check with them to see if they can see if the mail server logs say anything interesting.
I guess it's possible SAS somehow munged the file during upload. If you do a simple .pptx with just one slide from PROC PRINT, does the email work?
The usual way to add an email attachment that is for a specific application is to use the CONTENT_TYPE option. Try something like this:
filename mymail email "[email protected]"
subject="PPT Test"
attach=("MyPPT.pptx" content_type="application/pptx");
data _null_;
file mymail;
put 'Hi Me,';
put 'This is a test.';
run;
If you copy a BINARY file as TEXT it can become corrupted.
Please share the code you used for FCOPY , in particular how you defined the two FILEREFs used. Make sure your are not using RECFM=V. Using RECFM=F is best, RECFM=N might work also.
RECFM= option was specified.RECFM= option was specified.
This worked fine for me. I created a test PPTX in Powerpoint, saved it to a SAS server folder, ran the below program. I just double-clicked on the email attachment and the Powerpoint opened as I expected:
filename mymail email "[email protected]"
subject="PPTX Test"
attach=("TestPPTX.pptx" content_type="application/pptx"
);
data _null_;
file mymail;
put 'Hi Me,';
put 'This is a test.';
run;
This is the test email:
@bijayadhikar wrote:
Sorry for typo. PPTX was not copied as text.
Why do you think that?
Try being specific in how you want SAS to read and write the files when copying.
filename src "&pptpath" recfm=f lrecl=512;
filename dst "&pptlocal" recfm=f lrecl=512;
Also make sure to tell the email process what type of file it is attaching, this will help the recipient know what application to use to open the file. It will also help with email filters.
filename mymail email
to = "my.email@com"
subject = "Monthly Performance Deck"
attach = ("&pptlocal" content_type="application/pptx")
;
Thank you very much TOM. The FCOPY with RECFM=f did work; however PowerPoint repair warning keeps coming. When I use RECFM=n, the warning is no longer coming. Here is my script that worked well.
%put &=pptpath;
/*Window explorer: FILE SIZE=1495 KB*/
%let pptlocal=....\COPIED_TEST_Report.pptx;
filename src "&pptpath" recfm=f lrecl=512;
filename dst "&pptlocal" recfm=f lrecl=512;
/* Copy PPTX */
data _null_;
rc=fcopy('src','dst');
put "FCOPY RC=" rc;
run;
/*Log: FCOPY RC=0*/
/*verify copied file*/
filename chk "&pptlocal";
data _null_;
fid=fopen('chk');
if fid > 0 then do;
size=finfo(fid,'File Size (bytes)');
put 'COPIED FILE SIZE=' size;
rc=fclose(fid);
end;
else put 'FILE COULD NOT BE OPENED';
run;
/*Log: COPIED FILE SIZE=1495 KB*/
filename chk "&pptlocal";
filename mymail email
to = "my.email@com"
subject = "Monthly Performance Deck"
attach = (
"&pptlocal"
content_type="application/pptx"
)
;
/* Write the email body */
data _null_;
file mymail;
put "Hello,";
put ;
put "Please find the attached PowerPoint presentation for your review.";
put ;
put "Best regards,";
put "CD Team";
run;
Conclusion:
Using FCOPY with recfm=f:
filename src "&pptpath" recfm=f lrecl=512;
filename dst "&pptlocal" recfm=f lrecl=512;
I successfully produced a full-sized PPTX copy (1,495 KB). The emailed attachment is no longer truncated and opens successfully after repair. The original issue of receiving a 514–579 byte attachment appears resolved. The remaining issue is that PowerPoint still displays a repair prompt before opening the emailed PPTX.
Question
Given that:
The original and copied PPTX files are both math 1,495 KB
The copied file opens normally outside Outlook
The emailed attachment is no longer truncated
PowerPoint still performs a repair when opening the attachment
It did work nicely except repair warning
However, I use RECFM=N option no longer receives warning.
filename src "&pptpath" recfm=n lrecl=512;
filename dst "&pptlocal" recfm=n lrecl=512;
1) Try this code
filename src "&pptpath"; filename dst "&pptlocal"; -------> filename src "&pptpath" recfm=n; filename dst "&pptlocal" recfm=n;
https://blogs.sas.com/content/sasdummy/2013/09/17/copy-file-macro/
2) Try RENAME() function:
data _null_;
rc=rename("c:\old\x.pptx","c:\new\x.pptx",'file');
put rc= ;
run;
Thank you Ksharp. Appreciated for help., I did not try renaming but using recfm=n stopped PowerPoint repair warning.
filename src "&pptpath" recfm=n; filename dst "&pptlocal" recfm=n;
Nearly 200 sessions are now available on demand in the Innovate Hub.
Watch Now →Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.