sravantarun
sravantarun

Reputation: 31

How to embed image and table(proc print) in the body of email? SAS

I had image saved in one location. I am able to send image in the body of an email and I am able to send table(using proc print) in the body of an email.

The problem is I am not able to put both image and table in the body of an email.

Here is the code i tried

filename report "c:/users/test.html";
filename SEND email to ="*****@****.com"
                from="****@****.com"
            attach=("/C/users/graph1.png" name="testgraph1" inlined="logo1") 
                content_type="text/html";

ods html file=report;
proc print data=test;
run;
ods html close;


data _null_;
infile report;
file SEND;
input;
put _infile_;
put "<img src='id:logo1'/>";
run;

Upvotes: 1

Views: 5310

Answers (1)

Thogerar
Thogerar

Reputation: 339

I think there is a mistake in the pathname you are using, this should be better:

attach=("c:\users\graph1.png")

I find also an example here :

First part :

options emailsys = SMTP;

options emailhost = my.smtp.server;

filename myemail EMAIL
    to=("[email protected]")
 from="FROM NAME <[email protected]>"
 sender="FROM NAME <[email protected]>"
 /*importance="HIGH"*/
 subject = "Subject"
 type = "text/html"
 attach =(
 "fullpath\header.png"
 );


ods listing close;

Second part :

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;

source: https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/Embed-an-image-in-Outlook-email-sent-using-SAS/td-p/159267

You have to use a proc report (or simply proc print) to embed a table in your email depending on what you want.

...
ods html text = "... next part of my email :"; 
PROC REPORT DATA=X nowd HEADLINE HEADSKIP
style (report) = {background = white
font_face = "Verdana" font_size = 7pt just=left }
style (column) = {background = white CELLHEIGHT = 2.5%
font_face = "Verdana" font_size = 7pt just=left}
style (header) = {foreground = cx5e2750 font_face="Verdana"
font_size = 8pt just=left
background = white} ;
columns
DATE
TIME
FN
C;
DEFINE DATE / 'Date';
define TIME / 'Time';
define FN / "File Name";
define C / "Run Number";
run;
ods html text = "Have a Great Day."; 
...

source: https://communities.sas.com/t5/ODS-and-Base-Reporting/Sending-emails-from-SAS-with-embedded-table-from-dataset/td-p/299263

Regards,

Upvotes: 1

Related Questions