Data visualization with SAS programming

Embed an image in Outlook email sent using SAS

Reply
Occasional Contributor
Posts: 12

Embed an image in Outlook email sent using SAS

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!

PROC Star
Posts: 1,322

Re: Embed an image in Outlook email sent using SAS

Posted in reply to path2success

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.

New User
Posts: 1

Re: Embed an image in Outlook email sent using SAS

Posted in reply to path2success

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.

Frequent Contributor
Posts: 96

Re: Embed an image in Outlook email sent using SAS

[ Edited ]

 

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;

 

 

Ask a Question
Discussion stats
  • 3 replies
  • 3274 views
  • 1 like
  • 4 in conversation