从 SAS 发送电子邮件,正文中包含报告和文本



我已经在SAS EG 7.2中创建了一个报告,并让SAS通过电子邮件在电子邮件正文中发送,但是我似乎无法添加任何文本。 我有这个代码:

filename mymail email   
to=('mail@email.com')
subject='Report'
from='mail@email.com'
Content_type="text/html";
ods _all_  close;
ODS ESCAPECHAR='^'; 
ods html body=mymail  style=minimal;
proc report data=data… 
…
run;
ods html close;
ods _all_ close;

这完美地发送了我的电子邮件。 我可以这样做来添加一些文本

filename mymail email   
to=('mail@email.com')
subject='Report'
from='mail@email.com'
Content_type="text/html";
ods _all_  close;
ODS ESCAPECHAR='^'; 
ods html body=mymail  style=minimal;
DATA _null_;
file mymail;
Put "Hello,"//
"You are recieving this mail because:"//;
if &warn1=1 then do;
put "&w1." //; end;
if &warn2=1 then do;
put "&w2." //; end;
put
"Regards,"//
"Chris";
run;
ods html close;
ods _all_ close;

但我似乎不能两者兼而有之? 如果我包括文本步骤和过程报告,则我只能在生成的电子邮件中看到报告。 有什么想法吗?

提前致谢:)

如果有人感兴趣,我设法通过在 proc 报告之前直接添加以下行来解决这个问题:

ods html text="<div>Please find below the Reports </div> <br><br> There are &&totalwarnings. warnings for the last hour:<br><br>";
%if &warn1=1 %then %do;
ods html text="&&w1."; %end;
%if &warn2=1 %then %do;
ods html text="&&w2."; %end;

将文本添加到 HTML 文件本身的解决方案听起来最好。

您的原始代码有几个问题。

首先,您有访问冲突。DATA _NULL_步骤是尝试写入 ODS HTML 进程仍在写入的同一文件。您没有收到错误消息吗? 或者也许是两封单独的电子邮件?

其次,即使您成功地将文本写入与ODS HTML生成的相同文件中,它也将在<HTML>之前或之后。在ODS HTML生成的报告周围</HTML>标记。 因此,收件人可能会忽略它。

相关内容

最新更新