BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
cxkev
Fluorite | Level 6

Hi,

I have created and exported an excel file (Using ODS tagsets,ExcelXP). Now am I trying to send that file via email with the following code:

%macro newrepmail (team, fileloc, recipient,desc);

FILENAME output EMAIL

SUBJECT="Test Subject"

FROM= "My Email Address"

TO= &recipient.

ATTACH=&fileloc.;

/* Sending email */

DATA _NULL_;

FILE output;

PUT "Test Body";

RUN;

%mend newrepmail;

%newrepmail (DLK,

             ("Location of the File"),

                ("Recipient"),

                WT MI);

I get the error: An attachment record was truncated. The attachment LRECL is too small.

Please can anyone advise of a way round this?

Many Thanks for your help,

cxkev


1 ACCEPTED SOLUTION

Accepted Solutions
WendyT
Pyrite | Level 9

Cxkev- I was wrestling with this same item this morning.  I have a monthly batch that sends QA notifications to folks, and it has run without problems for a couple of years under first 9.2, and now 9.3.

I found a problem note that suggested putting the lrecl= in the attachment specification, and it worked for me.  http://support.sas.com/kb/4/425.html

We are running 9.3 (TS1M2) via remote login to a Windows 2008 server.

Hope this helps!

WendyT

%LET DAYO=%SYSFUNC(TODAY(),YYMMDDN8.) ;

FILENAME SENDMAIL EMAIL        

SUBJECT="SAMPLE QA REPORT"        

FROM="WendyT@ouraddress.com"        

TO=("person1@ouraddress.com"             "person2@ouraddress.com")        

ATTACH=("&QA_REPORTS\Monthly_Sample_QA_Report_&DAYO..HTML" LRECL=9999) ;

DATA _NULL_ ;  

FILE SENDMAIL ;  

PUT "Coded sample results for the last 120 days are attached" ;  

PUT "  " ;  

RUN ;

View solution in original post

4 REPLIES 4
Amir
PROC Star

Hi,

I searched for the error messages you reported and found the following links:

39996 - "ERROR: An attachment record was truncated" when sending Excel files as email attachments fr...

40143 - E-mail output from SAS® 9.2 fails when attachments have an LRECL value greater than 1000

I'm not sure which platform you're running SAS on, so I'm not sure which (if any) apply.

As a side note, I could not see the "desc" macro function parameter being used anywhere - may be it is in your full code; and I would recommend avoid using SAS statements for naming purposes, e.g. "output".

Hope that helps.

Regards,

Amir.

WendyT
Pyrite | Level 9

Cxkev- I was wrestling with this same item this morning.  I have a monthly batch that sends QA notifications to folks, and it has run without problems for a couple of years under first 9.2, and now 9.3.

I found a problem note that suggested putting the lrecl= in the attachment specification, and it worked for me.  http://support.sas.com/kb/4/425.html

We are running 9.3 (TS1M2) via remote login to a Windows 2008 server.

Hope this helps!

WendyT

%LET DAYO=%SYSFUNC(TODAY(),YYMMDDN8.) ;

FILENAME SENDMAIL EMAIL        

SUBJECT="SAMPLE QA REPORT"        

FROM="WendyT@ouraddress.com"        

TO=("person1@ouraddress.com"             "person2@ouraddress.com")        

ATTACH=("&QA_REPORTS\Monthly_Sample_QA_Report_&DAYO..HTML" LRECL=9999) ;

DATA _NULL_ ;  

FILE SENDMAIL ;  

PUT "Coded sample results for the last 120 days are attached" ;  

PUT "  " ;  

RUN ;

cxkev
Fluorite | Level 6

Hi,

I tried that but I still got the same error message. I'm using SAS 9.2. There was a option to install a hot fix on teh SAS site but I don't have those privelages on my work PC.

To get round the issue I simply removed the long text columns in my report, and instead, input a hyperlink within the report to take the user to a seperate report which will include the long text. As the seperate report is not being emailed it doesn't encounter the same error.

Thanks everyone for your help.

bulewind
Fluorite | Level 6

can you try use 

 CONTENT_TYPE= (or CT=) option in the FILENAME statement for the attachment as shown in the example below:

   filename sendit email from="user@company.com"    to="someone@domain.com"    subject="Excel files from SAS"   attach=("myfile.xls" content_type="application/vnd.ms-excel");

 

official link: http://support.sas.com/kb/39/996.html

 

Mine works but my file corrupt, I guess because my SAS EG 4.3 version too lower.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 8573 views
  • 3 likes
  • 4 in conversation