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

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;

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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

View solution in original post

8 REPLIES 8
DanH_sas
SAS Super FREQ

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

to_the_point
Calcite | Level 5

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

DanH_sas
SAS Super FREQ

You can use goptions XPIXELS/YPIXELS or HSIZE/VSIZE to control the size of the graph in the PDF.

GraphGuy
Meteorite | Level 14

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(?)

to_the_point
Calcite | Level 5

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

GraphGuy
Meteorite | Level 14

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

to_the_point
Calcite | Level 5

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?

GraphGuy
Meteorite | Level 14

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:

8.3 filename - Wikipedia, the free encyclopedia

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 3523 views
  • 6 likes
  • 3 in conversation