BookmarkSubscribeRSS Feed
SteveFrensch
Calcite | Level 5
I have a quick question that I was hoping you might be able to help me with, I am trying to embed a graphic output into the body of an email, but have been having some problems. I can send an email, but there is not picture, just one of those red 'x' missing picture icons. I am running a batch script on a UNIX machine.

A few notes:

1. I can successfully send tables in the body, but the problem comes up when I try to add a graphic output.

2. The code I am using is below:

FILENAME OUTPUT EMAIL
SUBJECT = "&subject."
FROM = &fromEmail.
TO = &toEmail.
type='text/html'
CT ='text/html'
ATTACH='gplot.png'
;
goptions device=png;


** Create ODS HTML;
ods html
body=OUTPUT
device=PNG;
** Print the report to the ODS destination;
title 'Centigrade to Fahrenheit conversion table';
proc gplot data=temperatures;
plot centigrade*fahrenheit;
run;

ods html close;

3:The email does get sent, but there is not picture, just one of those red 'x' missing picture icons. When I look at the html from the message, I can see that the html is trying to referece 'gplot.gif', but cant find it. gplot.gif is created properly on the server, but is never sent out.

So my question is:

How do I get the graph to go along with email and show up in the body of the email?

Thanks in advance,

Steve
6 REPLIES 6
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Generate your graph first, to a specified output file destination. Then generate the EMAIL which also needs the accurate location of the generated image file with the ATTACH= parameter (if not choosing to embed the image in the EMAIL body. Your attachment must exist, before you can reference it in the FILENAME statement.

Scott Barry
SBBWorks, Inc.
dipakgopale
Calcite | Level 5
Hi


I'm Also facing same proble if u have code the please share to me

trying to display graph on mail body(Daily basis)

we need to create graph on daily and mail to user

please advice
SteveFrensch
Calcite | Level 5
Just a quick update to this problem, got most of it figured out in case anyone else is dealing with this.

1. The problem stemmed from the mail coming from UNIX. Sending binary attachments (as in a gif) require additional encoding.

2. The problem was solved by creating the html and accompanying gifs via ODS in SAS, and just leaving them on the server. Then using a UNIX script encode the graphics and generated the email headers.

3. The UNIX script needs to encode the gifs using uuencode.

i.e.: uuencode $att1 'gchart.gif' >UUENCODE_UOTPUT.tmp

4.Use UNIX to generate a MIME wrapper around the HTML and UUNECODE_OUTPUT, something like:

MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"
---q1w2e3r4t5
Content-Type: text/html
Content-Disposition: inline ;

$HTML_OUTPUT_FROM_SAS

---q1w2e3r4t5
Content-Type: image/gif; name="gchart.gif"
Content-Transfer-Encoding: uuencode
'Content-Disposition: attachment; filename="gchart.gif"

$UUENCODE_UOTPUT.tmp


With these MIME headers to tell outlook that you are sending an HTML and a gif the email comes through with active HTML embedded into the body of the email.

Hope this helps
anandbillava
Fluorite | Level 6
Hi Steve,
I am hanging on this problem now.. Can you please share your code.


Many thanks in advance
dipakgopale
Calcite | Level 5

Hi Anand 

 

I'm Also facing same proble if u have code the please share to me 

 

trying to display graph on mail body(Daily basis)

 

we need to create graph on daily and mail to user

 

please advice

dipakgopale
Calcite | Level 5
Hi

I'm Also facing same proble if u have code the please share to me

trying to display graph on mail body(Daily basis)

we need to create graph on daily and mail to user

please advice

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
  • 6 replies
  • 4539 views
  • 0 likes
  • 4 in conversation