BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
K_HARI__PRASAD
Calcite | Level 5

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.

useridmailid
100abc@some.com
101def@some.com
102ghi@some.com
103jkl@some.com
104mno@some.com
105pqr@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;

1 ACCEPTED SOLUTION

Accepted Solutions
esjackso
Quartz | Level 8

I think you can skip the counter and use:

if mod(_n_,200) = 0 then sleep(2);

Eric

View solution in original post

15 REPLIES 15
esjackso
Quartz | Level 8

I think you can skip the counter and use:

if mod(_n_,200) = 0 then sleep(2);

Eric

Kurt_Bremser
Super User

Of course, but calling the mod() function with every iteration may unnecessarily eat CPU cycles. Blame it on the old-school programmer in me Smiley Happy

K_HARI__PRASAD
Calcite | Level 5


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.

K_HARI__PRASAD
Calcite | Level 5

: Thanks for the information provided.

Yes you are right ,I am able to send mail a maximum of 499 after that I am getting that ERROR message.

K_HARI__PRASAD
Calcite | Level 5

: Yeh now its not throwing error. But still I am unable to send the mails after 499 records eventhough I included the call sleep in the data step.

Kurt_Bremser
Super User

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.

K_HARI__PRASAD
Calcite | Level 5

: Yes you are right. But its related to production.Hence the data will increase gradually and the number of tables also will be increase.

K_HARI__PRASAD
Calcite | Level 5

: Yes we need to right the macro.

jakarman
Barite | Level 11

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?

---->-- ja karman --<-----
jakarman
Barite | Level 11

Why not talk to the mail-server administrator, he had control on that number of mails.

---->-- ja karman --<-----
K_HARI__PRASAD
Calcite | Level 5

: I am not aware like whether the mail-server admin can have the control over the number of mails to be trigger. I need to investigate on this more.

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!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 15 replies
  • 3659 views
  • 6 likes
  • 4 in conversation