BookmarkSubscribeRSS Feed
Fluorite | Level 6


Is there a possible way,  using SAS we could send out an outlook email with a screenshot or picture embedded within the email? It is not an attachment. Basically as soon as the email recipient opens the email he/she should be able to see the screenshot/picture.

I know the part of sending out the emails via SAS but I am not sure if we can embed a picture along with the email content?

Could you please share your tips and knowledge on this topic?

Thank you!



This isn't quite what you were looking for, but Robert Allison has a nice post describing using html5 to embed an image in an html file. But his suggestion for emailing it is to attach the html file, rather than have it actually be the body of the messsage.

I think the problem is that while most modern browsers support html5 (or at least mostly support it), many email clients (e.g. Outlook) may not. I wonder if it would be worth trying to send the email in RTF format instead of HTML?  RTF can embed images.... I've never tried that.


Check out the Boston Area SAS Users Group (BASUG) video archives:
Calcite | Level 5


i hope solution will still be relevant to you, if not i think it might be usefull for anyone landing on this page Smiley Happy

I'm working on v9.2

FILENAME myemail EMAIL from=""

encoding='wlatin2'  /* i use it for east european characters */

to = ""

subject = "solution to display image in email body"

type = "text/html"

attach = "fullPath\imagename.png"


ods listing close; /* close default ods */

ods html body=myemail options(pagebreak="no") style=myHTML rs=none; /* start ods to html with options, rs=none forces ODS to perform record based output */

data _null_; /* embed attached image */

ods html text = '<img src = "imagename.png""></img>';


ods _all_close; /* close all (html) ods */

Attached file should appear in body content, at least it does in outlook 2007 and 2010.

Quartz | Level 8


Thanks David,

I'll just add that the image file must not have any space in its name (cost me a good hour to figure out what was wrong).  

I'll add that escapechars and html tag can both be used, like in this example :



options emailsys = SMTP;

options emailhost = my.smtp.server;

filename myemail EMAIL
 from="FROM NAME <>"
 sender="FROM NAME <>"
 subject = "Subject"
 type = "text/html"
 attach =(

ods listing close;


ods html body=myemail options(pagebreak="no") style=sasweb rs=none; /* start ods to html with options, rs=none forces ODS to perform record based output */ title; ods escapechar="^"; ods html text= '<img src="./header.png" alt="header">'; ods html text= "<p>Blah blah blah,</p>"; ods html text= "<p>Blah blah blah blah ^S={font_style=italic}BLAH^S={}..</p>"; ods html text= "<p>blah <a href='' target='_blank'></a>.</p>"; ods html text= "<p>^S={font_weight=bold}First Lastname^S={}<br> Division<br> Company inc.</p>"; ods _all_ close;



Quartz | Level 8

Can't be done using only SAS unfortunately - SAS doesn't support embedding images into an email in a manner that outlook will display.  Not entirely SAS's fault 😉


'Rich' emails were implemented haphazardly in general.  Outlook still uses the HTML engine from word to render/display them which gives you an idea of the kind of uphill battle you're fighting.  Most CSS is not recognized, and the CSS it does recognize is incredibly finicky.


Also see:


Despite all of these issues, I've had success in the past using "blat" (a 3rd party emailing tool) to embed images into emails in a manner that mixes multiple images (charts) and HTML tables together and presents them in a consistent manner across mobile email readers + outlook clients.  In order to do this I basically created HTML files that referred to the image in standard <IMAGE> tags, then used the -embed command line option in blat to attach the images (which are sent as their own MIME parts I guess).  Outlook was then able to render them successfully.  It's a serious investment in time to get working, much easier to just attach as a PDF or image unfortunately.



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. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 4 replies
  • 5 in conversation