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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP mail bugs?

Status
Not open for further replies.

Ragol1

Programmer
Oct 25, 2001
315
US
Im getting two or three emails everytime asp email is used.

I have checked the code and it only has one recipient once but I get three email every time.

Help

Nick
 
Can you post your code so that we can look it over?
 
Sure here
Thanks

<%
<%
Set mail = Server.CreateObject(&quot;Persits.Mailsender&quot;)
Mail.Host = &quot;mymailserver.com&quot;


strEmail = request.form(&quot;Email&quot;)
strUser = request.form(&quot;User&quot;)
strLevel = request.form(&quot;Level&quot;)
strHours = request.form(&quot;Hours&quot;)
strMag = request.form(&quot;Mag&quot;)
strStyle = request.form(&quot;Style&quot;)
strVeralt = request.form(&quot;Veralt&quot;)
strPassword = request.form(&quot;Password&quot;)
strCard = request.form(&quot;Card&quot;)

Mail.From = strEmail
Mail.FromName = strUser
Mail.AddBCC &quot;Webmaster@mysite.com&quot;
'Mail.AddBCC &quot;anotheremailaddress@hotmail.com&quot;
'Mail.AddAddress strEmail
'Mail.AddReplyTo strEmail
'Mail.AddAttachment &quot;c:\any file&quot;
strBodyHeader = &quot;A Member has updated their Stats&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Level : &quot; & strLevel & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Hours : &quot; & strHours & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Mag : &quot; & strMag & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Version : &quot; & strVeralt & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Style : &quot; & strStyle & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Password : &quot; & strPassword & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Card Number : &quot; & strCard & chr(13) & chr(10)
strBody = strBodyHeader & strBody
Mail.Subject = &quot;A Member has updated their stats&quot;
Mail.body = strBody
'Mail.Body = &quot;Dear Fan:&quot; & Chr(13) & Chr(10) & &quot;Thank you for your business.&quot;


On Error Resume Next
Mail.Send
If Err <> 0 Then
Response.Write &quot;Error encountered: &quot; & Err.Description
End If
%>
<%
ID = request.querystring(&quot;ID&quot;)
UserId = request.form(&quot;UserId&quot;)
Name = request.form(&quot;Name&quot;)
Password = request.form(&quot;Password&quot;)
Level = request.form(&quot;Level&quot;)
Hours = request.form(&quot;Hours&quot;)
Veralt = request.form(&quot;Veralt&quot;)
Mag = request.form(&quot;Mag&quot;)
Style = request.form(&quot;Style&quot;)
Card = request.form(&quot;Card&quot;)
update_date = request.form(&quot;update_date&quot;)



' declaring variables
' not neccesary but a good habit
Dim DataConn
Dim UpdateRecord
Dim MYSQL

Set DataConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Set UpdateRecord = Server.CreateObject(&quot;ADODB.Recordset&quot;)

DataConn.Open &quot;PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=E:\mydatabase.mdb&quot;

MYSQL = &quot;SELECT mine.* FROM mine WHERE (ID = &quot; & ID & &quot;)&quot;

UpdateRecord.Open MYSQL, DataConn, 1, 3


UpdateRecord.Fields(&quot;Password&quot;) = Password
UpdateRecord.Fields(&quot;Level&quot;) = Level
UpdateRecord.Fields(&quot;Hours&quot;) = Hours
UpdateRecord.Fields(&quot;Mag&quot;) = Mag
'UpdateRecord.Fields(&quot;System&quot;) = System
UpdateRecord.Fields(&quot;update_date&quot;) = update_date
UpdateRecord.Fields(&quot;Veralt&quot;) = Veralt


UpdateRecord.Update


UpdateRecord.Close
Set UpdateRecord= Nothing
DataConn.Close
Set DataConn = Nothing


'Response.Write &quot;Information Updated&quot;
%><title>Info Updated</title>
<body bgcolor=&quot;#000000&quot; text=&quot;#FFCC00&quot;>
<p>&nbsp;</p>
<div id=&quot;Layer1&quot; style=&quot;position:absolute; left:34px; top:17px; width:629px; height:87px; z-index:1&quot;><img src=&quot;../Pics/rr_banner2.jpg&quot; width=&quot;576&quot; height=&quot;180&quot;></div>
<div align=&quot;center&quot;>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Thank you your info has been updated</p>
<p>Go back to Members seciton<a href=&quot;../Members.asp&quot;> Click Here.</a></p>
</div>
 
Is this happening in testing (from yourself) or in production (from users)?
 
Both

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(&quot;.&quot;) & &quot;\users.mdb&quot;
ConnectStr = &quot;DRIVER={Microsoft Access Driver (*.mdb)};DBQ=&quot; & strDbPath

Set rs = Server.CreateObject(&quot;adodb.recordset&quot;)
rs.Open &quot;Users&quot;, ConnectStr, 2, 3

If Request(&quot;Send&quot;) <> &quot;&quot; Then
' send email to all users
Set Mail = Server.CreateObject(&quot;Persits.MailSender&quot;)
Mail.Host = &quot;mymailserver.com&quot;

strShip = request(&quot;ship&quot;)
strBlock = request(&quot;block&quot;)
strLobby = request(&quot;lobby&quot;)
strLoc = request(&quot;Loc&quot;)
strpcship = request(&quot;pcship&quot;)
strpcblock = request(&quot;pcblock&quot;)
strpclobby = request(&quot;pclobby&quot;)
strpcloc = request(&quot;pcloc&quot;)
strPassword = request(&quot;password&quot;)


Mail.From = &quot;Webmaster@mysite.com.com&quot;
Mail.FromName = &quot;Webmaster&quot;
strBodyHeader = &quot;Greetings fellow Raiders!&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Here is today's game play information.&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;If you do not receive an e-mail tomorrow please continue to use the game play information provided below.&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is Todays DC Ship : &quot; & strShip & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is The DC Location : &quot; & strLoc & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is Todays DC Block : &quot; & strBlock & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is Todays DC Lobby : &quot; & strLobby & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;&quot; & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;&quot; & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is Todays PC Ship : &quot; & strpcship & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is The PC Location : &quot; & strpcloc & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is Todays PC Block : &quot; & strpcblock & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is Todays PC Lobby : &quot; & strpclobby & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;&quot; & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;&quot; & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;This is Todays Password : &quot; & strPassword & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;A few reminders:&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;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.&quot; & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;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.&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;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.&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Please exchange .&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;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.&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;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.)&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBodyHeader = strBodyHeader & &quot;Please reply with any comments and/or suggestions.&quot; & chr(13) & chr(10) & chr(13) & chr(10)
strBody = strBodyHeader & strBody
Mail.Subject = &quot;Todays Ship/Block and Password&quot;
Mail.body = strBody
While not rs.EOF
Mail.AddBcc rs(&quot;Email&quot;)
rs.MoveNext
Wend

' finally: send message
Mail.Send

Response.Write &quot;Success!&quot;
Else
' simply display the list of users in the database
Response.Write &quot;<B>Currently in the user database:</B><P>&quot;
While not rs.EOF
Response.Write rs(&quot;UserID&quot;) & &quot; (&quot; & rs(&quot;Email&quot;) & &quot;)<BR>&quot;
rs.MoveNext
Wend
End If
%>
 
[bugeyed] I have no idea.


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.)

Kris
 
Where and what would I add.

Thanks

Nick
 
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.

Kris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top