我有一个数据集(work.employees),其中每个字段都是要发送的电子邮件的元素。示例记录:Smith,John,John.Smith @ Company.com,JohnsManager @ Company.com。对于每条记录,我需要根据其中的信息发送单独的电子邮件。我可以发送一封包含宏变量的电子邮件,并且已经发布了数据 null 电子邮件,但迭代并未发生。建议将非常感谢。感谢。
答案 0 :(得分:0)
所以你想通过sas发送电子邮件通知?问题是两个折叠。首先,您需要确保在SAS中正确配置了SMTP服务器。其次,您必须制作所需的邮件软件。
首先按照http://support.sas.com/kb/19/767.html
中的指南进行操作现在你想要的(显然)是解析/选择电子邮件。我假设您只从数据集中选择它们。
Proc sql;
select distinct(emails) into: resplist separated by ' ' from mail_set where emails like '%@%';
/*Here I'm selecting only those that have @ mark in the cells.
You can add parser as you need. (question is a bit oddly worded.*/
quit;
或者,您可以硬编码地址。 (我建议你先试试这个,这样你就知道你的发送代码是有效的了。
%let respList="Frist.last@email.com" "Second.Recipiant@email.com";
FILENAME Mailbox EMAIL &respList.
Subject="Email delivery for you";
DATA _NULL_;
FILE Mailbox;
PUT "Good day,";
put ;
PUT "Remain calm. This is a test.";
PUT ;
run;
您还可以添加sas数据集信息,但请记住,通过电子邮件发送垃圾邮件通常是个坏主意。
答案 1 :(得分:0)
If you want to send one email per record, it's better to use the !EM_
directives in your datastep.
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002058232.htm
filename reports email "Jim.Smith@work.com"; data _null_; file reports; length name dept $ 21; input name dept; put '!EM_TO! ' name; put '!EM_SUBJECT! Report for ' dept; put name ','; put 'Here is the latest report for ' dept '.' ; if dept='marketing' then put '!EM_ATTACH! c:\mktrept.txt'; else /* ATTACH the appropriate report */ put '!EM_ATTACH! c:\devrept.txt'; put '!EM_SEND!'; put '!EM_NEWMSG!'; put '!EM_ABORT!'; datalines; Susan marketing Peter marketing Alma development Andre development ; run;