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

Discussion in 'ASP General' started by whyyyy, Jul 10, 2006.

  1. whyyyy

    whyyyy Guest

    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=" "
    MyMail.To=""
    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



    <%
    dim email
    email=Request.Form("email")
    If email<>"" Then
    Response.Write("Hello " & email & "!<br />")
    Response.Write("We have receved your submission")
    End If
    %>
    whyyyy, Jul 10, 2006
    #1
    1. Advertising

  2. whyyyy

    James Jones Guest

    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=" "
    MyMail.To=""
    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














    "whyyyy" <> wrote in message news:...
    > 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=" "
    > MyMail.To=""
    > 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
    >
    >
    >
    > <%
    > dim email
    > email=Request.Form("email")
    > If email<>"" Then
    > Response.Write("Hello " & email & "!<br />")
    > Response.Write("We have receved your submission")
    > End If
    > %>
    James Jones, Jul 13, 2006
    #2
    1. Advertising

  3. whyyyy

    alan Guest

    Re: CDO.Message sent whenever page loads, though the form not subm

    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


    --
    AL


    "James Jones" wrote:

    > 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=" "
    > MyMail.To=""
    > 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
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > "whyyyy" <> wrote in message news:...
    > > 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=" "
    > > MyMail.To=""
    > > 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
    > >
    > >
    > >
    > > <%
    > > dim email
    > > email=Request.Form("email")
    > > If email<>"" Then
    > > Response.Write("Hello " & email & "!<br />")
    > > Response.Write("We have receved your submission")
    > > End If
    > > %>
    alan, Jul 13, 2006
    #3
  4. whyyyy

    alan Guest

    Re: Gratitude

    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=""
    MyMail.To=" "
    MyMail.Cc=""
    MyMail.Bcc=""
    MyMail.Subject="Ropa de Arte y Cuero"
    MyMail.Send()
    Set MyMail=Nothing
    Response.Redirect "confirmed.asp?email=" & email
    Else
    %>
    --
    AL


    "James Jones" wrote:

    > 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=" "
    > MyMail.To=""
    > 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
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    > "whyyyy" <> wrote in message news:...
    > > 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=" "
    > > MyMail.To=""
    > > 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
    > >
    > >
    > >
    > > <%
    > > dim email
    > > email=Request.Form("email")
    > > If email<>"" Then
    > > Response.Write("Hello " & email & "!<br />")
    > > Response.Write("We have receved your submission")
    > > End If
    > > %>
    alan, Jul 13, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TWljaGFlbA==?=
    Replies:
    1
    Views:
    2,802
    Andy Miller
    Jul 24, 2004
  2. christopherbouy
    Replies:
    0
    Views:
    507
    christopherbouy
    Aug 1, 2007
  3. Andy B
    Replies:
    9
    Views:
    531
    Andy B
    Nov 19, 2007
  4. John Kotuby
    Replies:
    5
    Views:
    6,266
    John Kotuby
    Jun 24, 2008
  5. aryan
    Replies:
    2
    Views:
    90
    GArlington
    Sep 10, 2008
Loading...

Share This Page