The SAS Output Delivery System and reporting techniques

Graphics in Body of Email

Reply
New Contributor
Posts: 3

Graphics in Body of Email

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
Super Contributor
Super Contributor
Posts: 3,174

Re: Graphics in Body of Email

Posted in reply to SteveFrensch
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.
Contributor
Posts: 24

Re: Graphics in Body of Email

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
New Contributor
Posts: 3

Re: Graphics in Body of Email

Posted in reply to SteveFrensch
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
Contributor
Posts: 72

Re: Graphics in Body of Email

Posted in reply to SteveFrensch
Hi Steve,
I am hanging on this problem now.. Can you please share your code.


Many thanks in advance
Contributor
Posts: 24

Re: Graphics in Body of Email

Posted in reply to anandbillava

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

Contributor
Posts: 24

Re: Graphics in Body of Email

Posted in reply to SteveFrensch
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
Ask a Question
Discussion stats
  • 6 replies
  • 2723 views
  • 0 likes
  • 4 in conversation