DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   ASP (http://www.daniweb.com/forums/forum62.html)
-   -   Form sends email for every page load (http://www.daniweb.com/forums/thread198748.html)

nukedfood Jun 20th, 2009 3:51 pm
Form sends email for every page load
 
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:

Dim objConfig  ' As CDO.Configuration
Dim objMessage ' As CDO.Message
Dim Fields    ' As ADODB.Fields
Dim title, firstname, surname, email, confirmemail, reason, other, enquiry

title = Request.Form("title")
firstname = Request.Form("firstname")
surname = Request.Form("surname")
email = Request.Form("email")
confirmemail = Request.Form("confirmemail")
reason = Request.Form("reason")
other = Request.Form("other")
enquiry = Request.Form("enquiry")

' Get a handle on the config object and it's fields
Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

' Set config fields we care about
With Fields
        .Item(cdoSendUsingMethod)      = cdoSendUsingPort
        .Item(cdoSMTPServer)            = "smtp.somesite.co.uk"
        .Item(cdoSMTPServerPort)        = 25
        .Item(cdoSMTPConnectionTimeout) = 10
        .Item(cdoSMTPAuthenticate)      = cdoBasic
        .Item(cdoSendUserName)          = "me@somesite.co.uk"
        .Item(cdoSendPassword)          = "password"

        .Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
        .To      = "someone@something.com"
        .From    = "someone@something.co.uk"
        .Subject  = "Customer Enquiry"
        .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
        .Send
       
End With

Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
%>

Does anyone have any ideas?

Cheers.

chsab420 Jun 25th, 2009 6:34 am
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


All times are GMT -4. The time now is 9:52 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC