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!
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.
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.
Hi,
i hope solution will still be relevant to you, if not i think it might be usefull for anyone landing on this page
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.
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;
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.