I use the same code to send a daily email to users in a DB and it only sends one, here it is below , it seems when it reads from a DB it only sends one but when it send to an address it sends 3
<%
' connect to the MS Access database in the same directory
strDbPath = Server.MapPath("." & "\users.mdb"
ConnectStr = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & strDbPath
Set rs = Server.CreateObject("adodb.recordset"
rs.Open "Users", ConnectStr, 2, 3
If Request("Send" <> "" Then
' send email to all users
Set Mail = Server.CreateObject("Persits.MailSender"
Mail.Host = "mymailserver.com"
Mail.From = "Webmaster@mysite.com.com"
Mail.FromName = "Webmaster"
strBodyHeader = "Greetings fellow Raiders!" & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "Here is today's game play information." & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "If you do not receive an e-mail tomorrow please continue to use the game play information provided below." & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "This is Todays DC Ship : " & strShip & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "This is The DC Location : " & strLoc & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "This is Todays DC Block : " & strBlock & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "This is Todays DC Lobby : " & strLobby & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "" & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "" & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "This is Todays PC Ship : " & strpcship & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "This is The PC Location : " & strpcloc & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "This is Todays PC Block : " & strpcblock & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "This is Todays PC Lobby : " & strpclobby & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "" & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "" & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "This is Todays Password : " & strPassword & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "A few reminders:" & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "Please do not give out the passwords to players who are not members of RR. If you wish to play with friends who are not RR members, please do so in a NON RR game." & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "Also, please do not type the password in the lobby. If someone asks you for the password, make sure you are certain that they are a member and only give it to them via the game's simple mail funtion." & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "Whenever you create a room, please precede the name of the room with the letters RR - this will designate the room as an official Ragol Raiders' game." & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "Please exchange ." & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "If you want to see a listing of current members you can always search for other clanmates by clikcing on the list all members button located at the bottom of the members page." & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "We encourage you to use the calendar tool located within the members page to post your game times and activities (e.g., quests, battle, challenge, etc.)" & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & "Please reply with any comments and/or suggestions." & chr(13) & chr(10) & chr(13) & chr(10)
strBody = strBodyHeader & strBody
Mail.Subject = "Todays Ship/Block and Password"
Mail.body = strBody
While not rs.EOF
Mail.AddBcc rs("Email"
rs.MoveNext
Wend
' finally: send message
Mail.Send
Response.Write "Success!"
Else
' simply display the list of users in the database
Response.Write "<B>Currently in the user database:</B><P>"
While not rs.EOF
Response.Write rs("UserID" & " (" & rs("Email" & "<BR>"
rs.MoveNext
Wend
End If
%>
Maybe add a persistant variable (cookie or session var or ...) with an value that changes each time it is hit and add that to the email. This might tell you if the code is looping. (If all the values are different in each email then the code is looping.)
You just need to setup a variable (like a number) in something that you can always reference (like a cookie) and in your body of the message pull the value from the cookie then add 1 to the value and stick that in the email and write the new value to the cookie.
Start Web Page
Write Cookie with value of 1
Run Email Code
Pull Cookie Value of 1
Add 1 to the Cookie Value
Stick this new value in the email
ReWrite the Cookie with the new value.
If the emails have different values then your code is looping somewhere, if not then you sorta wasted your time.
I would first test the looping with a simple email that you plan to loop several times to make sure the value is incrementing. Then move that code to your real problem.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.