BookmarkSubscribeRSS Feed
path2success
Fluorite | Level 6

Hi,

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!

4 REPLIES 4
Quentin
Super User

Hi,

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.

http://blogs.sas.com/content/sastraining/2013/11/06/sas-9-4-has-a-new-way-to-send-interactive-graphs...

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.

--Q.

The Boston Area SAS Users Group (BASUG) is hosting our in person SAS Blowout on Oct 18!
This full-day event in Cambridge, Mass features four presenters from SAS, presenting on a range of SAS 9 programming topics. Pre-registration by Oct 15 is required.
Full details and registration info at https://www.basug.org/events.
David86
Calcite | Level 5

Hi,

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="your@email.com"

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

to = "recepient@email.com"

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>';

run;

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

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

morglum
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
    to=("TO_ADDRESS@domain.com")
 from="FROM NAME <from.name@domain.com>"
 sender="FROM NAME <from.name@domain.com>"
 /*importance="HIGH"*/
 subject = "Subject"
 type = "text/html"
 attach =(
 "fullpath\header.png"
 );


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='www.blah.com' target='_blank'>www.blah.com</a>.</p>"; ods html text= "<p>^S={font_weight=bold}First Lastname^S={}<br> Division<br> Company inc.</p>"; ods _all_ close;

 

 

RobP
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:

https://stackoverflow.com/questions/16242489/send-a-base64-image-in-html-email

 

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.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 4 replies
  • 11866 views
  • 2 likes
  • 5 in conversation