CDO.Message sent whenever page loads, though the form not submitte

W

whyyyy

The script below works fine if the form is filled out and submitted.

But a (blank) e-mail is sent whenever the page loads, even when the form is
not submitted. I would like to receive the e-mail only when the form is
submitted


<%@LANGUAGE="VBSCRIPT"%>
<%
Set MyMail=CreateObject("CDO.Message")
MyMail.TextBody=Request.Form("name") & vbCrLf & _
Request.Form("email")& vbCrLf & _
Request.Form("phone")& vbCrLf & _
Request.Form("palaver")
MyMail.From=" (e-mail address removed)"
MyMail.To="(e-mail address removed)"
MyMail.Cc=""
MyMail.Bcc=""
MyMail.Subject="cosas de cuero"
MyMail.Send()
Set MyMail=Nothing
%>

Part two: The script below could be part of the problem. It is in the html
body below the closing form tag </form> and works when the form is submitted,
but I would prefer not to use it, but instead to have a redirect to a
confirmation page.

But if I use "response.redirect", the page with the form never opens. Only
the confirmation page opens.

So I have two questions, and am obviously a novice.

This forum has been a lifesaver in the past

Thanks

Alan Lipman
(e-mail address removed)
(e-mail address removed)

<%
dim email
email=Request.Form("email")
If email<>"" Then
Response.Write("Hello " & email & "!<br />")
Response.Write("We have receved your submission")
End If
%>
 
J

James Jones

seems that you do not understand what they are trying to do. So instead of using other things such as requesting the method, we will do it all by form then......


here is what your basic code should look like............

you need to put YOUR form into the section that says "YOUR FORM CODE WILL NEED TO BE HERE"......

you will also need to add this line of code into your form:

<input type="hidden" name="action" value="send">




i really hope this helps.





*************EMAIL PAGE BEGIN**************


<%@LANGUAGE="VBSCRIPT"%>
<%
Dim action
action = Request.Form("action")

IF action = "send" Then
Dim email
email = request.form("email")

Set MyMail=CreateObject("CDO.Message")
MyMail.TextBody=Request.Form("name") & vbCrLf & _
Request.Form("email")& vbCrLf & _
Request.Form("phone")& vbCrLf & _
Request.Form("palaver")
MyMail.From=" (e-mail address removed)"
MyMail.To="(e-mail address removed)"
MyMail.Cc=""
MyMail.Bcc=""
MyMail.Subject="cosas de cuero"
MyMail.Send()
Set MyMail=Nothing
Response.Redirect "confirm.asp?email=" & email
Else
%>

************YOUR FORM CODE WILL NEED TO BE HERE....***************
ex...

<form action="email.asp" method="post">
<input type="hidden" name="action" value="send"> *******YOU NEED TO ADD THIS TO YOUR FORM AS A HIDDEN FIELD FOR THIS TO WORK!!!
<input type="submit" value="Send Email">
</form>

<%
End IF
%>


****************EMAIL PAGE END******************



****************CONFRMATION PAGE BEGIN*******************

<%
Dim email
email = Request.QueryString("email")
%>

Hello <%=email%>! <br />
We have received your submission.


**************CONFIRMATION PAGE END***********************














James Jones
 
A

alan

To James Jones and Aaron.

Thank you both for new approaches

"seems that you do not understand what they are trying to do" -- You got
that right
 
A

alan

Dear James

The script below with the hidden field works perfectly. I needed only the
response redirect so didn't use any asp below the </FORM> except this:
<%
End IF
%>

Again thank you and many blessings: Your help with this did the job

I apologoze to the others for my God-given ignorance

Thanks Again


<%@LANGUAGE="VBSCRIPT"%>
<%
Dim action
action = Request.Form("action")
IF action = "send" Then
Dim email
email = request.form("email")
Set MyMail=CreateObject("CDO.Message")
MyMail.TextBody=Request.Form("name") & vbCrLf & _
Request.Form("email")& vbCrLf & _
Request.Form("phone")& vbCrLf & _
Request.Form("palaver")
MyMail.From="(e-mail address removed)"
MyMail.To=" (e-mail address removed)"
MyMail.Cc="(e-mail address removed)"
MyMail.Bcc=""
MyMail.Subject="Ropa de Arte y Cuero"
MyMail.Send()
Set MyMail=Nothing
Response.Redirect "confirmed.asp?email=" & email
Else
%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top