I'm using SAS 9.4 to generate a HTML5 file, works just fine, but when attaching the file to an email, I get the "ERROR: An attachment record was truncated. The attachment LRECL is too small." error. I previously got this error in 9.2 and it was fixed by adding the (content_type="text/HTML") from this support paper:
http://support.sas.com/kb/39/996.html
But for HTML5, it doesn't seem to work, nor does setting LRECL=9999, as other workarounds have suggested. Any thoughts?
goptions device=png xpixels=1200 ypixels=900;
ODS LISTING CLOSE;
ODS HTML5 options (bitmap_mode='inline')
path='my_path' body="Chart.htm" style=egdefault;
goptions noborder cback=white gunit=pct htitle=6 htext=1.5 ftitle="albany amt/bold" ftext="albany amt";
title1 ls=2 "Title 1";
title2 ls=1 color=red "(Mouse over circles for more info)";
footnote;
symbol1 interpol=join value=dot color=blue height=3;
axis1 order=(70 to 90 by 2)
label=("Metric")
minor=none
offset=(1,1)
width=1;
axis2 order=("01JAN13"d to "31DEC14"d by month)
label=none
value=(angle=45)
offset=(0,0)
minor=none;
proc gplot data=my_data;
plot metric*week / grid vaxis=axis1 haxis=axis2 html=my_html des='' cframe=bwh;
run;
quit;
ODS HTML CLOSE;
ODS LISTING;
option emailhost='localhost';
filename mymail email
from = "my_email"
to = "my_email"
sender="my_email"
subject="Test HTML"
attach = ("my_path/Chart.htm" lrecl=9999)
content_type="text/HTML";
data _null_;
file mymail;
run;
Looks like the bitmap for the graph generates a "line" much in excess of any expected text line size.
Take a look at the generated file and see what is in there, maybe a further increase of lrecl may help.
Another option could be to avoid the "inline" graphics, set ODS so that all output (including the graphs) are stored in a single directory, and then attach all files in the directory to the email, with correct type specification.
Just came to my mind: what if you zip the .htm and attach the zipped file with a correct filetype?
Looks like the bitmap for the graph generates a "line" much in excess of any expected text line size.
Take a look at the generated file and see what is in there, maybe a further increase of lrecl may help.
Another option could be to avoid the "inline" graphics, set ODS so that all output (including the graphs) are stored in a single directory, and then attach all files in the directory to the email, with correct type specification.
Just came to my mind: what if you zip the .htm and attach the zipped file with a correct filetype?
The generated graph is only 110 KB, but it does appear that upping the LRECL = 9999999 seems to work (999999 sent the email without the error, but the file wouldn't open). Does the LRECL statement tie directly to file size?
LRECL => Logical RECord Length , related to the length of any single record. In tabular data that usually corresponds to the content of a single row. Image files however tend not to have a "row" content, just one big long sequence or a single record.
You'll note that the original fix related to Text, not Image which is another type of content.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.