Mail triggering issue

Results 1 to 2 of 2

Thread: Mail triggering issue

  1. #1
    Join Date
    Dec 1969

    Default Mail triggering issue

    I have a problem with my mail system, which is that some people (not all) complain of receiving 3 (never 2 or 4) copies of my weekly email...<BR><BR>Each week&#039;s mail has a unique title (eg 20Feb05) and the SQL query picks out those who do not have a record with that title, sends them an email and then updates the record with that title. So they should only get one...<BR><BR>The code for this bit is below....<BR><BR><BR><BR>strSQL= "SELECT TOP 5000 Email, Sent, SiteID, Maildate, CoreMail "&_<BR>"FROM CandidatesCJ WHERE CoreMail = &#039;Y&#039; AND SiteID = "&iSiteID&" "&_ <BR>"AND Sent &#060;&#062; &#039;"& strTitle&"&#039; AND strSearch is Null AND Sent &#060;&#062; &#039;error&#039; "&_ <BR>"AND Entrydate &#060; GetDate()-1 ORDER BY CandidatesID"<BR><BR><BR>objRec.Open strSQL, objConn, , adLockPessimistic, adCmdText<BR><BR>If objRec.EOF Then<BR>&#039;None left to send - reset everything<BR>Application.Lock<BR>Application("Run Mail")= 0<BR>Application("Title")=""<BR>Application("textv ersion")=""<BR>Application("HTMLversion")=""<BR>Ap plication("NextBatchTime")=""<BR>Application.Unloc k<BR><BR>End if<BR><BR>Do while not objRec.EOF<BR>strEmail = objRec("Email")<BR><BR><BR>Set Mail = Server.CreateObject("Persits.MailSender")<BR>Mail. Host = "localhost"<BR>Mail.From = ""<BR>Mail.FromName = "MySite"<BR>Mail.AddAddress ""& strEmail &""<BR>Mail.AddCustomHeader "Bounce-From: "& strEmail<BR>Mail.Subject = "Weekly Email"<BR>Mail.Body = ""& strHTML &""<BR>Mail.AltBody = ""& strText &""<BR><BR>Err.Clear <BR>On Error Resume Next <BR> Mail.Send <BR>On Error GoTo 0 <BR>If Err &#060;&#062; 0 Then <BR>&#039;Response.write ("Error mailing to ")<BR>&#039;Response.write strEmail<BR>objRec("Sent")= "error"<BR>objRec.Update <BR><BR>else<BR>objRec("Maildate") = date<BR>objRec("Sent")= strTitle<BR>objRec.Update<BR>end if<BR><BR>Set Mail = nothing<BR>objRec.MoveNext<BR><BR>Loop<BR><BR>objR ec.Close<BR>...<BR><BR><BR>The other important thing to point out is that the mail is sent in BATCHES. So there is some code on this page which sets the next batch time, like this...<BR><BR>Application.Lock<BR>If Application("NextBatchTime")&#060; Now() Then<BR>NewTime = Application("NextBatchTime") <BR>NewTime = DateAdd("n", 50, NewTime)<BR>Application("NextBatchTime")=NewTime<B R>End if<BR>Application.Unlock<BR><BR>This is then triggered from the Home page. So the first person to visit after NextBatchTime will trigger the sending of the next batch.<BR><BR>This all works fine apart from some triplicates. Could this be something to do with multiple people hitting the Home page right on NextBatchTime (but then I am locking my Application). Alternatively, could it be something to do with a batch not all being sent before the next one is triggered (don&#039;t think so, because I stretched this out - 5000 every 50 minutes - and I still get the error).<BR><BR>Any ideas?

  2. #2
    Join Date
    Dec 1969

    Default You dont show

    how you handle updating the app variables...<BR><BR>Now couple things...<BR>5000 emails in 1 go seems like alot...<BR>persists mailer handles appx 100 mails a minute<BR>(so they claim)<BR>so thats about 5000 mails in 50 mins... (APPX.)<BR>Could me more, could be alot less if server is under heavy load...<BR><BR>Could also be coding...<BR><BR>Do you loop through database<BR>and send out all the emails (according to your code)<BR>then when done<BR>update the application variables to hold the<BR>(last mailed ID)<BR>so you know where to pick up from on the next batch?<BR><BR>If so that could be your problem...<BR>so maybe your script is timing out periodically <BR>(during peek times maybe)<BR>And the application variables are not being updated properly...<BR>therefor running again... sending some duplicates...<BR><BR>Food for thought.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts