I'm trying to distribute an email with an attached HTML file to myself with a set of data attached, I can create the file I want to send (displays correctly in SAS and through other applications is i open directly) and I can attach the file and it sends. However, when I open the attachment I get the red 'X' indicating it can't find the file. The source code doesn't have a path to the .png but is pointing at the correct graphic name. I'm using SAS 9.3 on a 64bit Windows server (2008). I've found a similar problem someone posted on a UNIX server but their solution was the uuencode unix command option which I don't believe there is an equivalent to in SAS. Code is:
/* adapted from Rob Allison's Stock Table */
goptions ftitle="albany amt" ftext="albany amt" ctext=gray22 htitle=14pt htext=8pt;
ODS LISTING CLOSE;
ODS HTML path=odsout body="&name..htm" gpath=odsout (title="SAS/Graph Portfolio Table") options(pagebreak='no') style=minimal;
symbol1 value=none interpol=join color=cx00cc00; /* green line */
symbol2 value=dot h=5pt interpol=none color=cx42c3ff; /* bright blue - high value */
symbol3 value=dot h=5pt interpol=none color=cxf755b5; /* red/pink - low value */
axis1 style=0 label=none major=none minor=none value=none offset=(0,0);
axis2 style=0 label=none major=none minor=none value=none offset=(45,40);
title1 "***********";
title2 height=20pt " ";
footnote1 j=r c=gray "Note: Each sparkline is independently auto-scaled";
proc gplot data=plotdata anno=anno_table
plot norm_A*mindate=1 high_A*mindate=2 low_A*mindate=3 / overlay skipmiss
autovref cvref=graydd
vaxis=axis1
haxis=axis2
noframe
anno=anno_lines
des='' name="&name";
run;
quit;
ods html close ;
ods listing ;
options emailsys=smtp emailhost="my.company.com" emailport=25;
filename mymail email
to="me@mycompany.com"
from="Me<me@mycompany.com>"
replyto="me@mycompany.com"
subject="Tracker"
attach="\\drivelocation\table.htm"; /* this is the hardcode name of &name above*/
data _null_;
file mymail;
put 'here is the latest report';
put 'file:\\drivelocation\table.htm';
/* another small issue is that the drive location has a space and therefore doesn't resolve in the email with a link correctly - anyone have a quick workaround? */
run;
Because of the disconnect between HTML files and images they reference, e-mailing HTML can be very problematic. A better solution might be to use PDF or RTF files instead because the graphics are directly embedded in the file. To try this out, change your code to be:
ods pdf file="\\drivelocation\table.pdf";
/* the plot */
ods pdf close;
Change the "attach=" to reference "\\drivelocation\table.pdf".
Hope this helps!
Dan
Because of the disconnect between HTML files and images they reference, e-mailing HTML can be very problematic. A better solution might be to use PDF or RTF files instead because the graphics are directly embedded in the file. To try this out, change your code to be:
ods pdf file="\\drivelocation\table.pdf";
/* the plot */
ods pdf close;
Change the "attach=" to reference "\\drivelocation\table.pdf".
Hope this helps!
Dan
Thanks, this has worked as a PDF but I had tried the RTF approach earlier without success. The PDF approach stretches the graph to the full page, but as I have more data to add it may well work better! Thanks
You can use goptions XPIXELS/YPIXELS or HSIZE/VSIZE to control the size of the graph in the PDF.
If you're just emailing a graph (rather than, say, a graph and a proc print table), you could maybe just email the .png file. You wouldn't be able to use any html mouse-over text or href drilldowns on the graph, but you might not be using those anyway(?)
Hi, I've been trying the .png approach but have been having trouble keeping the name the same, so although I can make it work once I've not been able to automate - I've tried deleting existing .png's with the X command but I can't get it to work. Thanks
If the name has already been used once during a SAS session, then SAS auto-increments a number onto the end of the name. To re-use the exact same name, you have to delete the grseg from the previous time. Tech support provides some code to help with this in the following help page...
38183 - "Error: Memname GSEG is unknown" might occur when running PROC GREPLAY
Thanks - very useful - one last question - how do I deal with putting drive names as a link when the drive names have a space in them? I vaguely remember using tilda's "~" but I'm not sure?
The drive name (such as "c:"), the filename, or both? And where are you using it? (in the body=, or the put statement, or other?)
If you post up the exact name, and where you're wanting to use it, somebody might be able to post up the exact answer.
In the meantime, the following page I found in a Web search has some info about shortening names:
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register 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.