Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wait window - slowing down 1

Status
Not open for further replies.
Oct 21, 2006
20
0
0
US
Merry Christmas. I want to slow this emailer down to two emails a minute since with smtp our server only lets us send out 10 every 5 minnutes. Any suggestions since I am looking for a way out.
=================================


SCAN FOR NOT EMPTY(EMail)
*** Send email
*** PARAMETERS Recipient email, Subject, Message, Attachment, Send To Name,
*** Sender EMail, Sender Name
=HBSendMail(cEmailMembers.EMail, This.txtsubject.Value, ;
This.Edit1.Value, ALLTRIM(This.txtAttachment.Value),
cEMailMembers.FullName, ;
This.txtSenderEMail.Value, This.txtEmailFrom.Value)
lnMailCount = lnMailCount + 1
IF lnMailCount > 1 AND INT(VAL(substr(TIME(),4,2))) = lnStartMin
DO WHILE INT(Val(substr(TIME(),4,2))) = lnStartMin
ENDDO
lnMailCount = 0
lnStartMin = INT(VAL(LEFT(TIME(),2)))
WAIT WINDOW "" TIMEOUT 55
ENDIF
ENDSCAN


Merry Christmas,

Charlesmac

wnscc@wnscc.org
 
WAIT WINDOW has one diadvantage, if the user press some button the program continue its execution, use API Sleep instead:
Code:
DECLARE Sleep IN WIN32API INTEGER
DO WHILE ...
   .....
   Sleep(5500) && 55 seconds
ENDDO

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
hELLO BORISLAV,

I CAN GET TWO EAMILS IN THE FIRST MINUTE (8OOpm) AND THEN I GET EIGHT MORE IN THE FIFTH MINUTE (804PM). HERE IS THE SUM THAT I PUT DOWN, 180000. MAKING THE NUMBER HIGHER DID SOLVE SOME OF THE PROBLEM BUT I ASK IN THE LONG RUN WITH 100, 1000 EMAIL. WILL IT BE EVEN?

IF lnMailCount > 1 AND INT(VAL(substr(TIME(),4,2))) = lnStartMin
DO WHILE INT(Val(substr(TIME(),4,2))) = lnStartMin
ENDDO
lnMailCount = 0
lnStartMin = INT(VAL(LEFT(TIME(),2)))
Sleep(180000) && 55 seconds
ENDIF
 
Parameter you pass to Sleep function is how many milliseconds the program must wait before continue its execution. There is some approximations, but I doubt that 2-3 milliseconds will be crucial for you (of course you know better than me).
And because I don't like empty loops why don't change the code to be:
Code:
IF lnMailCount > 1
   lnMailCount        = 0
   Sleep(60000) && 1 minute 
ENDIF

But, you talk about 1000 eMails and you are able to send only 10 within 5 min :) you will send them forever.
You could do something like:
Code:
ltStartDate = DATETIME()
lnMailCount = 0
SCAN FOR NOT EMPTY(EMail)
     =HBSendMail(cEmailMembers.EMail,;
                 This.txtsubject.Value, ;
                 This.Edit1.Value,;
                 ALLTRIM(This.txtAttachment.Value),;
                 cEMailMembers.FullName, ;
                 This.txtSenderEMail.Value,;
                 This.txtEmailFrom.Value)
       lnMailCount        = lnMailCount + 1
       IF lnMailCount > 5
          IF DATETIME() - ltStartDate < 10 * 3600 && 10 min.
             lnWaitTo10Min = (DATETIME() - ltStartDate)
             Sleep(lnWaitTo10Min * 1000)
          ENDIF
          ltStartDate = DATETIME()
          lnMailCount = 0
       ENDIF
ENDSCAN
not tested

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top