Hi,
I have to send emails from SAS by fetching the data from a data set. I have the mail ids around 5000. Hence I am getting "WARNING: Email service not available". Hence I would like to send the first 200 mails first and hold the process for few seconds and start the process to send 201 to 400 and hold the process for the same few seconds and so on.
My data set looks as follows.
userid | mailid |
---|---|
100 | abc@some.com |
101 | def@some.com |
102 | ghi@some.com |
103 | jkl@some.com |
104 | mno@some.com |
105 | pqr@some.com |
All these are unique mail ids.
I am new to SAS and I wrote the code as below..but I am getting "WARNING: Email service not available" becuase of SMTP server timeout or heavy load.
%macro email;
FILENAME file_mail EMAIL LRECL=3200 TYPE='text/html';
DATA _NULL_;
SET emails END=EOF;
BY mailid userid;
FILE file_mail;
put '!EM_TO!' mailid;
put '!EM_SUBJECT!' 'Test Plans have been created.';
put 'The following test plans have been created with you as a tester.';
put '<br>';
link = '<a href="' ||left(strip(userid)) || '">' ||'</a>'
put '!EM_SEND!';
put '!EM_NEWMSG!';
if EOF then
put '!EM_ABORT!';
RUN;
%mend;
%email;
I think you can skip the counter and use:
if mod(_n_,200) = 0 then sleep(2);
Eric
You could do this in the data step:
retain counter 0;
counter + 1;
if counter = 200 then do;
counter = 0;
sleep(2);
end;
I think you can skip the counter and use:
if mod(_n_,200) = 0 then sleep(2);
Eric
Of course, but calling the mod() function with every iteration may unnecessarily eat CPU cycles. Blame it on the old-school programmer in me
Thanks for your reply.
Its throwing an error after including the above either of the above two codes in DATA STEO, like
"ERROR: Undeclared array referenced: sleep."
Could you please write the entire code.
Many thanks in advance.
my bad; did some C lately, where one calls a function like a procedure.
use
call sleep(2);
instead of
sleep(2);
Then it is not a load problem, you most probably are not allowed to send >= 500 emails in one action.
So I'd suggest to split the data set into chunks < 500 and iterate through these with a macro.
Yes, you need to write the macro in a way to be flexible, so it does do your work for you in the future.
That number of 499 is weird a human setting to be expected at the server side. Is it possible?
- https://itservices.stanford.edu/service/emailcalendar/email/spam/limit (zimbra)
- Exchange Online Protection Limits | Exchange Online Protection Service Description (number of outbound message send)
The error message should probably not some unexplainable error but one telling a limit like this has been reached
Can you validate this?
Why not talk to the mail-server administrator, he had control on that number of mails.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.