How Do I send the current form as e-mail

Discussion in 'ASP General' started by Kassam, Jun 2, 2005.

  1. Kassam

    Kassam Guest

    Hi MVPs out there.

    I have constructed an order form and the users will enter the informtion. I
    now need to send the filled out form as an e-mail (body being the HTML with
    the fille din data) to a predefined e-mail address. I know how to use CDO. I
    don't want to go to another page to recontruct the HTML as the '.body'
    Thank you in anticipation.

    Kassam
     
    Kassam, Jun 2, 2005
    #1
    1. Advertising

  2. Kassam

    Jeff Cochran Guest

    On Thu, 2 Jun 2005 12:53:18 -0700, Kassam
    <> wrote:

    >Hi MVPs out there.
    >
    >I have constructed an order form and the users will enter the informtion. I
    >now need to send the filled out form as an e-mail (body being the HTML with
    >the fille din data) to a predefined e-mail address. I know how to use CDO. I
    >don't want to go to another page to recontruct the HTML as the '.body'
    >Thank you in anticipation.


    So don't go to another page, post back to the same page. Construct
    the body as you wish, and use variables for the form field values.
    Post back to the same form, and fill the values back into the form
    from the posted values at the same time as you fill in the body of the
    email. Use an If/Then to determine if the page has been posted back,
    using a hidden field, and if so, do the CDO bits.

    Jeff
     
    Jeff Cochran, Jun 3, 2005
    #2
    1. Advertising

  3. Kassam

    Roland Hall Guest

    "Jeff Cochran" wrote in message
    news:...
    : On Thu, 2 Jun 2005 12:53:18 -0700, Kassam
    : <> wrote:
    :
    : >Hi MVPs out there.
    : >
    : >I have constructed an order form and the users will enter the informtion.
    I
    : >now need to send the filled out form as an e-mail (body being the HTML
    with
    : >the fille din data) to a predefined e-mail address. I know how to use
    CDO. I
    : >don't want to go to another page to recontruct the HTML as the '.body'
    : >Thank you in anticipation.
    :
    : So don't go to another page, post back to the same page. Construct
    : the body as you wish, and use variables for the form field values.
    : Post back to the same form, and fill the values back into the form
    : from the posted values at the same time as you fill in the body of the
    : email. Use an If/Then to determine if the page has been posted back,
    : using a hidden field, and if so, do the CDO bits.

    To add to what Jeff wrote...

    I wrap my HTML in server-side VBScript as one string. Then when I post back
    to the same page, the string will be filled in with my input variables and
    that is the HTML content I send out with CDOSYS.

    I only send the output via mail if the form has been posted. An easy way to
    check is to add a name value pair to your submit button.

    sub prt(str)
    Response.Write str & vbCrLf
    end sub

    prt "<html>"
    prt "<body>"
    prt "<form action="""" method=""post"" />"
    prt "<input type=""text"" name=""iname"" value="""" /><br />"
    ' additional form input elements
    prt "<input type="submit" name="submit value="Submit" />"
    prt "</form>"
    prt "</body>"
    prt "</html>"

    Then put everything in this conditional to see if you post to the screen or
    send via mail.

    dim s, strName, valid
    strName = Server.HTMLEncode(Replace(Request.Form("iname"),"'","''"))
    s = Server.HTMLEncode(Replace(Request.Form("submit"),"'","''"))
    if s <> "" then
    ' validate input
    if valid then
    ' mail it
    prt "Thank you"
    prt "<span style=""cursor: pointer; border: 1px solid black;
    background-color: #efe"" onclick=""location.href='/'"">Continue</span>"
    Response.End
    else
    ' Post error
    ' Fall through to display form on screen
    end if
    end if

    None of this is tested for errors/typos.

    --
    Roland Hall
    /* This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose. */
    Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
    WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
    MSDN Library - http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Jun 3, 2005
    #3
    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. Nathan Sokalski
    Replies:
    3
    Views:
    1,985
    Larry Lard
    Nov 23, 2005
  2. =?Utf-8?B?Unlhbg==?=
    Replies:
    2
    Views:
    3,961
    Steven Cheng[MSFT]
    Feb 28, 2006
  3. refv8
    Replies:
    2
    Views:
    27,185
    ittower
    Oct 13, 2006
  4. Mike P
    Replies:
    1
    Views:
    587
    =?ISO-8859-1?Q?G=F6ran_Andersson?=
    Mar 1, 2007
  5. nauticalmac

    Mail insertion hack on Send Mail form

    nauticalmac, Dec 23, 2005, in forum: ASP General
    Replies:
    0
    Views:
    311
    nauticalmac
    Dec 23, 2005
Loading...

Share This Page