BookmarkSubscribeRSS Feed
micheal_page
Calcite | Level 5

HI.  

 

I am looking for help with a current challenge.   Hopefully this is an easy request.

 

I can send emails with an html table in the body and I can seen emails with attachments and text in the body, but I have not found a way to combine both of these.

 

I would like to send a email that has a summary table and comments in the body with an attachment or attachments.

 

Thank you for your help.

 

PS.   this is for a 9.3 environment running in linux

 

Here is my sample code.

 

/*email 1 attachment and text*/

FILENAME mymail EMAIL Attach="/appl/users/adminreports/exports/pdf/EarlyWarningTest.pdf"
from=("DoNotReply@email.com")
to=("user@email.com")
cc=("" )

subject="Early Warning Trends";

data _null_;
file mymail;

put 'This is a test.';


run; quit;

/*Email 2 html table*/

FILENAME mymail EMAIL
to=("user@email.com")
from=("DoNotReply@whirlpool.com")
subject="Early Warning Trends"
CONTENT_TYPE="text/html";

ODS LISTING CLOSE;
ODS HTML BODY=mymail;
PROC PRINT DATA=work.FLAGS_ALERT_1_TEST_2;
RUN;

ODS HTML CLOSE;
ODS LISTING;

5 REPLIES 5
ChrisNZ
Tourmaline | Level 20

What happens when your program runs? errors? email not as expected?

micheal_page
Calcite | Level 5
Hi. Thanks for your response.

The code runs. But it sends two emails.

I want all of the content to be sent in one email.
ChrisNZ
Tourmaline | Level 20

Mmm I am having trouble too.

 

Here is what I could do

 


data TEST; file "%sysfunc(pathname(work))/em.txt";  X=1; put X;run;

filename MYMAIL email attach      ="%sysfunc(pathname(work))/em.txt"
                      from        ="DoNotReply@email.com"
                      to          ="m771879@westpac.co.nz"
                      subject     ="test"
                      content_type="text/html" ;

ods listing close;

ods html file=MYMAIL(nobot);

option nocenter;
proc sql;
  select '<a>Hi all,<p>Here is the lastest report.</a>' from test(obs=1);
quit; 

option center;
proc print data=TEST;
run;
   
option nocenter;
proc sql;
  select '<a>Regards,<p>Your SAS guru</a>' from test(obs=1);
quit; 

ods html close;

ods listing;

which displays like this in Outlook:

 

Capture.PNG

 

 

 

micheal_page
Calcite | Level 5
This is working great. Thank you so much!
arpitagarwal512
Calcite | Level 5

this code is not working and gives me below error:

 

error line 49

 

1 The SAS System 12:03 Wednesday, March 28, 2018

1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Program (3)';
4 %LET _CLIENTPROJECTPATH='';
5 %LET _CLIENTPROJECTNAME='';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 GOPTIONS XPIXELS=0 YPIXELS=0;
11 FILENAME EGSR TEMP;
12 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
13 STYLE=HtmlBlue
14 STYLESHEET=(URL="file:///C:/Program%20Files/SASHome/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
15 NOGTITLE
16 NOGFOOTNOTE
17 GPATH=&sasworklocation
18 ENCODING=UTF8
19 options(rolap="on")
20 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21
22 GOPTIONS ACCESSIBLE;
23 data TEST; file "%sysfunc(pathname(work))/em.txt"; X=1; put X;run;

NOTE: The file "F:\work\_TD19524_AUMISSAS_\Prc2/em.txt" is:
Filename=F:\work\_TD19524_AUMISSAS_\Prc2\em.txt,
RECFM=V,LRECL=32767,File Size (bytes)=0,
Last Modified=28Mar2018:13:23:37,
Create Time=28Mar2018:13:23:37

NOTE: 1 record was written to the file "F:\work\_TD19524_AUMISSAS_\Prc2/em.txt".
The minimum record length was 1.
The maximum record length was 1.
NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds

24
25 filename MYMAIL email attach ="%sysfunc(pathname(work))/em.txt"
26
27 to ="arpit.agarwal@aubank.in"
28 subject ="test"
29 content_type="text/html" ;
30
31 ods listing close;
32
33 ods html file=MYMAIL(nobot);
NOTE: Writing HTML Body file: MYMAIL
34
35 option nocenter;
36 proc sql;
37 select '<a>Hi all,<p>Here is the lastest report.</a>' from test(obs=1);
38 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.03 seconds
2 The SAS System 12:03 Wednesday, March 28, 2018

cpu time 0.01 seconds

39
40 option center;
41 proc print data=TEST;
42 run;

NOTE: There were 1 observations read from the data set WORK.TEST.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds

43
44 option nocenter;
45 proc sql;
46 select '<a>Regards,<p>Your SAS guru</a>' from test(obs=1);
47 quit;
NOTE: PROCEDURE SQL used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

48
49 ods html close;
ERROR: Encryption Error: Invalid parameter.
50
51 ods listing;
52
53 GOPTIONS NOACCESSIBLE;
54 %LET _CLIENTTASKLABEL=;
55 %LET _CLIENTPROJECTPATH=;
56 %LET _CLIENTPROJECTNAME=;
57 %LET _SASPROGRAMFILE=;
58
59 ;*';*";*/;quit;run;
60 ODS _ALL_ CLOSE;
61
62
63 QUIT; RUN;
64

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
  • 5 replies
  • 3121 views
  • 0 likes
  • 3 in conversation