BookmarkSubscribeRSS Feed
JRD
Calcite | Level 5 JRD
Calcite | Level 5
I am new to SAS programming.

We use SAS program to run a SQL script and then place the output result in an email with HTML table. Now I am told to place a simple image as a header to this table.

The requirement is to embed the image to the email, so that when email is sent, the image will not be downloaded from the server to the user's desktop email, or their Blackberry (or iPhone) when they open the email.

I've tried using COMPUTE BEFORE and added the image thru the HTTP, however, I am asked to 'embedded' the image, so that it comes with the email.

Can you help me on this?
4 REPLIES 4
Cynthia_sas
SAS Super FREQ
Hi:
If you create the mail as RTF or PDF, then the image will be embedded in the single RTF or PDF file. If you create an HTML file, then, depending on your image type, etc, ODS HTML almost always generates an <IMG> tag.

I'm not sure what you mean by "added the image thru the HTTP" -- if you used PREIMAGE= or URL=, that will pretty much guarantee that an <IMG> tag is used for your image.

When you say that you are placing a simple image as a header to the table, is this a logo or company image? (As opposed to an image created with SAS/GRAPH??)

cynthia
JRD
Calcite | Level 5 JRD
Calcite | Level 5
Yes, the 'header' is the company logo. and I did try using PREIMAGE and then add it with an URL and it works, but it seems to be downloading the image when the email is opened.

But we really want it to be embedded so that when mail is opened on Outlook Express, Blackberry or iPhone, the image can be displayed without a problem.

How do I create the mail as RTF? And how do I add the image?

thanks for the help.
Cynthia_sas
SAS Super FREQ
Hi:
As you discovered, HTML works by using <IMG> tags; this is technically not embedding the image. An <IMG> tag is a pointer to the image location, frequently on a web server.As long as the folks receiving the email have a fast connection, the retrieval of the image from the server should be fairly speedy. However, in this day and age, most mail clients put a "hold" on the downloading of images from a server until the mail recepient explicitly asks for the images to be downloaded. This is due to security reasons

To insert an image into an RTF (or PDF) file, you would use either the PREIMAGE style= attribute in the SAS title, the PREIMAGE in a style template or a PREIMAGE in the table header to insert an image into an RTF document.

When ODS creates the RTF file or PDF file, the image should be embedded into the document.

How you send the mail is a different story. Do you want to send the email as an attachment? If so, you would 1) create your RTF or PDF file and then 2) use the RTF or PDF file name in the ATTACH= option on your FILENAME EMAIL statement.

If you want to write the RTF directly to the body of the email, then you might have to direct the ODS output to the FILENAME EMAIL statement; however, in this instance, you would also need to change the content-type of the mail to RTF as the MIME header. Do keep in mind that many email servers will display the RTF control strings, but will not render the control strings. As it explains in this paper, if you send RTF in the body of an email, you may need to save the RTF to a text file and then open the newly saved RTF file with Word.
Paper Reference: http://www2.sas.com/proceedings/forum2008/038-2008.pdf

The method shown below worked for me to send either the RTF or the PDF file as an attachment. When I opened the mail and then opened the attachment on my laptop, I saw the images in the SAS Title area and in the table header area -- for both types of attachment. However, on my iPhone I could only open the PDF attachment, because I do not have a word processor on the iPhone that would read RTF.

cynthia
[pre]
** Method 1: send email with attachment;
ods pdf file='c:\temp\testlogo.pdf';
ods rtf file='c:\temp\testlogo.rtf';
ods escapechar='^';
title '^S={protectspecialchars=off preimage="c:\temp\greencheck.jpg"} Green Check Image';

proc report data=sashelp.class(obs=5) nowd
style(report)={preimage="c:\temp\greencheck.jpg"};
run;
ods _all_ close;


filename doemail email to='xxx.yyy@company.com'
from='zzzzzzzz@cccccc.net'
subject='Testing attach of rtf'
attach='c:\temp\testlogo.rtf';
data _null_;
file doemail;
put 'this is a test with attachment.';
put 'RTF file has image';
run;

filename doemail clear;

filename pdf2mail email to='xxx.yyy@company.com'
from='zzzzzzzz@cccccc.net'
subject='new Testing attach of pdf'
attach='c:\temp\testlogo.pdf';
data _null_;
file pdf2mail;
put 'this is a test with attachment.';
put 'PDF file has image';
put 'is it on the iPhone?';
run;

filename pdf2mail clear;
[/pre]
JRD
Calcite | Level 5 JRD
Calcite | Level 5
Thanks, Cynthia, for the explanation and the help. This should give me a good direction to explore more.

Thanks again!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 6959 views
  • 0 likes
  • 2 in conversation