943,685 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Unsolved
  • Views: 1112
  • ASP RSS
Jun 20th, 2009
0

Form sends email for every page load

Expand Post »
Hi, I built a form to send customer info and used some ASP I found on the internet so I'm quite new to it. I got it to send the info I want but I recieve an e-mail every time I navigate away from the page not using the submit button. Here's the ASP I'm using to do it with:

ASP Syntax (Toggle Plain Text)
  1. Dim objConfig ' As CDO.Configuration
  2. Dim objMessage ' As CDO.Message
  3. Dim Fields ' As ADODB.Fields
  4. Dim title, firstname, surname, email, confirmemail, reason, other, enquiry
  5.  
  6. title = Request.Form("title")
  7. firstname = Request.Form("firstname")
  8. surname = Request.Form("surname")
  9. email = Request.Form("email")
  10. confirmemail = Request.Form("confirmemail")
  11. reason = Request.Form("reason")
  12. other = Request.Form("other")
  13. enquiry = Request.Form("enquiry")
  14.  
  15. ' Get a handle on the config object and it's fields
  16. Set objConfig = Server.CreateObject("CDO.Configuration")
  17. Set Fields = objConfig.Fields
  18.  
  19. ' Set config fields we care about
  20. With Fields
  21. .Item(cdoSendUsingMethod) = cdoSendUsingPort
  22. .Item(cdoSMTPServer) = "smtp.somesite.co.uk"
  23. .Item(cdoSMTPServerPort) = 25
  24. .Item(cdoSMTPConnectionTimeout) = 10
  25. .Item(cdoSMTPAuthenticate) = cdoBasic
  26. .Item(cdoSendUserName) = "me@somesite.co.uk"
  27. .Item(cdoSendPassword) = "password"
  28.  
  29. .Update
  30. End With
  31.  
  32. Set objMessage = Server.CreateObject("CDO.Message")
  33.  
  34. Set objMessage.Configuration = objConfig
  35.  
  36. With objMessage
  37. .To = "someone@something.com"
  38. .From = "someone@something.co.uk"
  39. .Subject = "Customer Enquiry"
  40. .TextBody = "SMTP Relay Test Sent @ " & Now() & vbCrLf & "title: " & title & vbCrLf & "firstname: " & firstname & vbCrLf & "surname: " & surname & vbCrLf & "email: " & email & vbCrLf & "confirmemail: " & confirmemail & vbCrLf & "reason: " & reason & vbCrLf & "other: " & other & vbCrLf & "enquiry: " & enquiry
  41. .Send
  42.  
  43. End With
  44.  
  45. Set Fields = Nothing
  46. Set objMessage = Nothing
  47. Set objConfig = Nothing
  48. %>

Does anyone have any ideas?

Cheers.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nukedfood is offline Offline
2 posts
since Jun 2009
Jun 25th, 2009
0

Re: Form sends email for every page load

do u want to send email when he clicks submit button
if so please give ur html code as well
Reputation Points: 10
Solved Threads: 5
Newbie Poster
chsab420 is offline Offline
23 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: cdosys help needed
Next Thread in ASP Forum Timeline: CDOSYS problems





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC