SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Problem with send email

    Hi there, I need your help.

    This is the script for send email to subscribers in my mailing list.
    I don't have ASP error but the Count variable does not increment for each send email.

    The variable Count is always 625 value.

    Why?
    Can you help me?
    Thank you in advance, I hope your help.
    Code:
    Function JSRedirect(Byval seconds)
    	With Response
    		.Write("<script language=""JavaScript"">" & vbCrLf) 
    		.Write("<!--" & vbCrLf) 
    		.Write("function redirect() {" & vbCrLf) 
    		.Write("window.location = '" & url & "';" & vbCrLf) 
    		.Write("}" & vbCrLf) 
    		.Write("timer = setTimeout('redirect()', '" & (seconds * 1500) & "');" & vbCrLf) 
    		.Write("-->" & vbCrLf) 
    		.Write("</script>" & vbCrLf) 
    	End With
    End Function
    
    SQL = " SELECT A.*, B.emails "
    SQL = SQL & " FROM tbl_login A "
    SQL = SQL & " JOIN tbl_ml B ON A.email = B.emails "
    SQL = SQL & " WHERE 1 "
    SQL = SQL & " AND `SendEmail` = 0 "
    SQL = SQL & " ORDER BY ID DESC "
    SQL = SQL & " LIMIT 25 "
    
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.Open SQL, objconn
    
    if objRS.eof then
       response.redirect("go.asp")
    else
    Count = 0
    
    while not objRS.eof 
    
    //.... script ASP CDOSYS for send emails
    
    str_update = "UPDATE tbl_ml SET "
    str_update = str_update & " `SendEmail` = 1 "
    str_update = str_update & " WHERE id = " & objRS("Id")
    objconn.execute (str_update)
    
    Count = Count + 25
    
    objRS.movenext
    wend
    
    response.write (JSRedirect(30))
    response.write "email sent: " & Count & " "
     
    end if
    
    objRS.Close
    Set objRS = Nothing

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2012
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't understand, as far as i can see, your code is working correctly.

    You select 25 records (LIMIT 25 in your sql)
    Add 25 to count for each row (i dont understand why it is 25 and not 1)
    so you see 625 ( 25 times 25) when all the mails are sent.


    What seems to be wrong ?

  3. #3
    SitePoint Evangelist cms9651's Avatar
    Join Date
    Mar 2010
    Posts
    407
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Flakes View Post
    I don't understand, as far as i can see, your code is working correctly.

    You select 25 records (LIMIT 25 in your sql)
    Add 25 to count for each row (i dont understand why it is 25 and not 1)
    so you see 625 ( 25 times 25) when all the mails are sent.


    What seems to be wrong ?
    thank you for reply.

    I solved with this query after str_update:
    Code:
    sql1 = "SELECT COUNT(*) AS NumberEmail FROM tbl_ml WHERE `SendEmail` = 1"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open sql1, objconn
    rs.MoveFirst
    Cont=rs.Fields("NumberEmail")
    rs.Close
    Thanks you very much for your help
    I'm really happy for your quickly answer.
    Good bye


Bookmarks

Posting Permissions

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