Problem sending data info with Jmail page.

Discussion in 'ASP General' started by Kingdom, Nov 26, 2003.

  1. Kingdom

    Kingdom Guest

    I have a SelectBoxes.asp page that is working with multiple selection
    dropdown boxes to extract data and total the selection prices.
    Tom & Bob were kind enough to give me a big help getting this page
    working and it's working just fine, no problems with this page.

    However I then would like this data e-mailed using jmail (my host insists
    on this method) and that is the function of the sendEMail2.asp page.

    This is failing and only giving me a HTTP 500 - Internal server error and
    I'm at a loss as to what's wrong.

    Any help/sugestions with this would be appreciated, code for both pages
    below.

    =========================================================================
    SelectBoxes.asp
    =========================================================================

    <%@ Language=VBScript %>
    <% Option Explicit
    Response.Expires = -10000


    Dim mComponentRS
    Set mComponentRS = Server.CreateObject("ADODB.RecordSet")

    Sub GetComponentNameAndPrice(aComponentID, byref aConnection, byref
    aComponentName, byref aComponentPrice)
    Dim mComponentSQL

    mComponentSQL = "select " &_
    "component_name," &_
    "price " &_
    "from " &_
    "parts_table " &_
    "where " &_
    "uniqueid = " & aComponentID

    mComponentRS.Open mComponentSQL, aConnection

    If mComponentRS.EOF Then
    aComponentName = ""
    aComponentPrice = 0
    Else
    aComponentName = mComponentRS("component_name")
    aComponentPrice = mComponentRS("price")
    End If

    mComponentRS.Close
    End Sub

    %>
    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-
    1252">
    <meta http-equiv="Content-Language" content="en-us">
    <title>Build PC</title>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">

    <style fprolloverstyle>A:hover {color: red; font-weight: bold}
    </style>

    <meta name="Microsoft Theme" content="tp-or12 1110">
    <meta name="Microsoft Border" content="tlb, default">
    </head>

    <BODY>
    <font color="#000080" size="2"> <span lang="en-gb"><font face="Arial">
    <br>
    You can now design your own custom built system
    online using our component database. <br>
    Select the parts you require from the dropdown selections then click <b>
    Go</b>
    to display your selection here.<b><br>
    </b></font>
    </span></font><font face="Arial"><Br>

    <%
    Dim sConnectionString
    'sConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
    Server.MapPath("\data\databasedb.mdb")
    sConnectionString="dsn=database1"
    %>
    <%
    Dim oCN
    Dim oRS
    Dim sSQL

    sSQL="SELECT UniqueID, Component_Type, Price, Component_Name, Image
    FROM Parts_Table ORDER BY Component_Type, Component_Name"
    Set oCN=CreateObject("ADODB.Connection")
    oCN.Open sConnectionString
    Set oRS=oCN.Execute(sSQL)


    'FOR Display & DEBUGGING

    If Request.Form("Case") <> "" Then
    Dim field
    Dim mComponentName, mComponentPrice, mComponentTotal
    mComponentTotal = 0

    Response.Write "<form method=""post""
    action=""SendEMail2.asp"">"

    Response.Write "<table border='0' cellspacing='1'
    cellpadding='1' width='400'>"
    Response.Write "<tr><td><b>Component</b></td><td
    align='right'><b>£</b></td></tr>"

    Dim mComponentCount
    mComponentCount = 0

    for each field in Request.Form
    mComponentCount = mComponentCount + 1

    'Response.Write "<li>" & Request.Form(field) & ": " &
    field & "</li>"

    GetComponentNameAndPrice Request.Form(field), oCN,
    mComponentName, mComponentPrice

    Response.Write "<tr>"

    Response.Write "<td>" & mComponentName
    Response.Write "<input type='hidden' name='Component" &
    mComponentCount & "' value='" & mComponentName & "' />"
    Response.Write "</td>"

    Response.Write "<td align='right'>" & mComponentPrice
    Response.Write "<input type='hidden'
    name='ComponentPrice" & mComponentCount & "' value='" & mComponentPrice &
    "' />"
    Response.Write "</td>"

    Response.Write "</tr>"

    mComponentTotal = mComponentTotal + mComponentPrice
    Next

    Response.Write "<tr><td align='right'><b>Total:</b></td><td>
    £" & mComponentTotal
    Response.Write "<input type='hidden'
    name='ComponentPriceTotal' value='" & mComponentTotal & "' />"
    Response.Write "<input type='hidden' name='ComponentCount'
    value='" & mComponentCount & "' />"
    Response.Write "</td></tr>"

    'END Display & DEBUGGING

    Response.Write "<tr><td colspan='2'>"
    Response.Write "This is not a sale, no payment is requsted at
    this time. Please submit your order and a member of our sales team will
    contact you."
    Response.Write "</td></tr>"

    Response.Write "</table>"

    Response.Write "<input type=""submit"" value="" Submit to
    sales team "" />"
    Response.Write "</form>"
    End If

    %> </font>

    <br /><br />

    <form method=Post action=SelectBoxes.asp>
    </form>
    <% call GetSelectBoxes%>
    <font face="Arial">

    <table border="0" cellspacing="0">
    <tr>
    <td>
    <input type=submit value=Go> <span lang="en-gb"></span>
    </form>
    </td>
    <td>
    <form method="post" action="SelectBoxes.asp"><input type="submit"
    value=" Reset " /></form></font>
    </form>
    </td>
    </table>

    <font face="Arial" size="2">You can make as many changes as you require,
    just select
    <b>Go</b> again to update</font>

    <%
    Sub GetSelectBoxes()

    if not oRS.EOF then
    Dim sCurrentBox
    Dim bIsFirst
    bIsFirst=true


    Dim mCurrentSelectedValue

    Do While not oRS.EOF
    'OK, we have our recordset.
    'Let's go through each "thingy" and create a box for
    it.
    if sCurrentBox <> oRS.Fields("Component_Type") then

    'it's time for a new select box.
    'but first, let's close the last box.
    if bIsFirst=false then
    'make sure it's not the first select box.
    Response.Write "</select><br>" & vbCrLf
    else
    bIsFirst=false
    end if

    'Create a line space between each box
    Response.Write ("<br>")
    'OK, create the new box.

    sCurrentBox=oRS.Fields("Component_Type")
    mCurrentSelectedValue = Request.Form(sCurrentBox)

    Response.Write sCurrentBox & ": <select name=""" & sCurrentBox
    & """>" & vbCrLf

    end if

    'Now add the individual item
    Response.Write vbTab & "<option value=""" & oRS.Fields
    ("UniqueID") & """"

    If mCurrentSelectedValue <> "" Then
    If mCurrentSelectedValue = CStr(trim(oRS.Fields
    ("uniqueid"))) Then
    Response.Write " selected "
    End If
    End If

    Response.Write ">" & trim(oRS.Fields("Component_Name")) & " :
    " & " £" & trim(oRS.Fields("Price")) & "</option>" & vbCrLf


    oRS.MoveNext

    Loop

    'Let's close that last one
    Response.Write "</select>" & vbCrLf


    end if

    Set oRS=nothing
    oCN.Close
    Set oCN=nothing
    End Sub

    %> </BODY>
    </HTML>


    ====================================================================
    sendEMail2.asp page
    ====================================================================

    <%
    Option Explicit
    Response.Expires = -10000
    %>



    <%

    Dim mEMailBody

    Dim mComponentLoop
    Dim mComponentCount

    mComponentCount = Request.Form("ComponentCount")

    Response.Write "This is the confirmation page.<br /><br />"

    mEMailBody = mEMailBody & "<table border='0' cellspacing='1'
    cellpadding='1' width='400'>"
    mEMailBody = mEMailBody & "<tr><td><b>Component</b></td><td
    align='right'><b>£</b></td></tr>"

    For mComponentLoop = 1 to mComponentCount
    mEMailBody = mEMailBody & "<tr>"
    mEMailBody = mEMailBody & "<td>" & Request.Form("Component" &
    mComponentLoop) & "</td>"
    mEMailBody = mEMailBody & "<td align='right'>" & Request.Form
    ("ComponentPrice" & mComponentLoop) & "</td>"
    mEMailBody = mEMailBody & "</tr>"
    Next

    mEMailBody = mEMailBody & "<tr><td align='right'><b>Total:</b></td><td>
    £" & Request.Form("ComponentPriceTotal") & "</td></tr>"
    mEMailBody = mEMailBody & "</table>"

    Response.Write mEMailBody


    'start email section

    Set JMail = Server.CreateObject ("JMail.SMTPMail")
    JMail.ServerAddress = "hostserver.net" 'actual server address removed
    JMail.Sender = Name
    JMail.ReplyTo = Email
    JMail.Subject = Subject
    JMail.AddRecipient Recipient
    JMail.Body = Name & Email & Tel & vbCrLf & BodyText
    JMail.Priority = 3
    JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
    JMail.Execute

    Response.Redirect("formthanks.html")
    Else
    'do nothing, just display blank form

    End IF
    ODBCConnection.Close
    Set ODBCConnection=Nothing

    Response.Write "<form method='post' action='SendEMail.asp'>"
    Response.Write "Name:<input type='text' name='Name' value='' /><br />"
    Response.Write "EMail Address:<input type='text' name='EMail' value='' />
    <br />"
    Response.Write "Tel No:<input type='text' name='Tel' value='' /><br />"
    Response.Write "<input type=""hidden"" name=""Recipient""
    value="""" /><br /> 'actual e-mail address removed
    Response.Write "<input type=""hidden"" name=""BodyText"" value=""" &
    mEMailBody & """ />"
    Response.Write "<input type=""submit"" value="" Send EMail "" /><br />"
    Response.Write "</form>"
    %>
    Kingdom, Nov 26, 2003
    #1
    1. Advertising

  2. Kingdom

    grw Guest

    IE > tools > options > advanced > DONT show friendly errors will give the
    true problem


    "Kingdom" <> wrote in message
    news:Xns943F789D2B956kingdomremovehotmail@194.117.133.134...
    >
    > I have a SelectBoxes.asp page that is working with multiple selection
    > dropdown boxes to extract data and total the selection prices.
    > Tom & Bob were kind enough to give me a big help getting this page
    > working and it's working just fine, no problems with this page.
    >
    > However I then would like this data e-mailed using jmail (my host insists
    > on this method) and that is the function of the sendEMail2.asp page.
    >
    > This is failing and only giving me a HTTP 500 - Internal server error and
    > I'm at a loss as to what's wrong.
    >
    > Any help/sugestions with this would be appreciated, code for both pages
    > below.
    >
    > =========================================================================
    > SelectBoxes.asp
    > =========================================================================
    >
    > <%@ Language=VBScript %>
    > <% Option Explicit
    > Response.Expires = -10000
    >
    >
    > Dim mComponentRS
    > Set mComponentRS = Server.CreateObject("ADODB.RecordSet")
    >
    > Sub GetComponentNameAndPrice(aComponentID, byref aConnection, byref
    > aComponentName, byref aComponentPrice)
    > Dim mComponentSQL
    >
    > mComponentSQL = "select " &_
    > "component_name," &_
    > "price " &_
    > "from " &_
    > "parts_table " &_
    > "where " &_
    > "uniqueid = " & aComponentID
    >
    > mComponentRS.Open mComponentSQL, aConnection
    >
    > If mComponentRS.EOF Then
    > aComponentName = ""
    > aComponentPrice = 0
    > Else
    > aComponentName = mComponentRS("component_name")
    > aComponentPrice = mComponentRS("price")
    > End If
    >
    > mComponentRS.Close
    > End Sub
    >
    > %>
    > <html>
    >
    > <head>
    > <meta http-equiv="Content-Type" content="text/html; charset=windows-
    > 1252">
    > <meta http-equiv="Content-Language" content="en-us">
    > <title>Build PC</title>
    > <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    > <meta name="ProgId" content="FrontPage.Editor.Document">
    >
    > <style fprolloverstyle>A:hover {color: red; font-weight: bold}
    > </style>
    >
    > <meta name="Microsoft Theme" content="tp-or12 1110">
    > <meta name="Microsoft Border" content="tlb, default">
    > </head>
    >
    > <BODY>
    > <font color="#000080" size="2"> <span lang="en-gb"><font face="Arial">
    > <br>
    > You can now design your own custom built system
    > online using our component database. <br>
    > Select the parts you require from the dropdown selections then click <b>
    > Go</b>
    > to display your selection here.<b><br>
    > </b></font>
    > </span></font><font face="Arial"><Br>
    >
    > <%
    > Dim sConnectionString
    > 'sConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" &
    > Server.MapPath("\data\databasedb.mdb")
    > sConnectionString="dsn=database1"
    > %>
    > <%
    > Dim oCN
    > Dim oRS
    > Dim sSQL
    >
    > sSQL="SELECT UniqueID, Component_Type, Price, Component_Name, Image
    > FROM Parts_Table ORDER BY Component_Type, Component_Name"
    > Set oCN=CreateObject("ADODB.Connection")
    > oCN.Open sConnectionString
    > Set oRS=oCN.Execute(sSQL)
    >
    >
    > 'FOR Display & DEBUGGING
    >
    > If Request.Form("Case") <> "" Then
    > Dim field
    > Dim mComponentName, mComponentPrice, mComponentTotal
    > mComponentTotal = 0
    >
    > Response.Write "<form method=""post""
    > action=""SendEMail2.asp"">"
    >
    > Response.Write "<table border='0' cellspacing='1'
    > cellpadding='1' width='400'>"
    > Response.Write "<tr><td><b>Component</b></td><td
    > align='right'><b>£</b></td></tr>"
    >
    > Dim mComponentCount
    > mComponentCount = 0
    >
    > for each field in Request.Form
    > mComponentCount = mComponentCount + 1
    >
    > 'Response.Write "<li>" & Request.Form(field) & ": " &
    > field & "</li>"
    >
    > GetComponentNameAndPrice Request.Form(field), oCN,
    > mComponentName, mComponentPrice
    >
    > Response.Write "<tr>"
    >
    > Response.Write "<td>" & mComponentName
    > Response.Write "<input type='hidden' name='Component" &
    > mComponentCount & "' value='" & mComponentName & "' />"
    > Response.Write "</td>"
    >
    > Response.Write "<td align='right'>" & mComponentPrice
    > Response.Write "<input type='hidden'
    > name='ComponentPrice" & mComponentCount & "' value='" & mComponentPrice &
    > "' />"
    > Response.Write "</td>"
    >
    > Response.Write "</tr>"
    >
    > mComponentTotal = mComponentTotal + mComponentPrice
    > Next
    >
    > Response.Write "<tr><td align='right'><b>Total:</b></td><td>
    > £" & mComponentTotal
    > Response.Write "<input type='hidden'
    > name='ComponentPriceTotal' value='" & mComponentTotal & "' />"
    > Response.Write "<input type='hidden' name='ComponentCount'
    > value='" & mComponentCount & "' />"
    > Response.Write "</td></tr>"
    >
    > 'END Display & DEBUGGING
    >
    > Response.Write "<tr><td colspan='2'>"
    > Response.Write "This is not a sale, no payment is requsted at
    > this time. Please submit your order and a member of our sales team will
    > contact you."
    > Response.Write "</td></tr>"
    >
    > Response.Write "</table>"
    >
    > Response.Write "<input type=""submit"" value="" Submit to
    > sales team "" />"
    > Response.Write "</form>"
    > End If
    >
    > %> </font>
    >
    > <br /><br />
    >
    > <form method=Post action=SelectBoxes.asp>
    > </form>
    > <% call GetSelectBoxes%>
    > <font face="Arial">
    >
    > <table border="0" cellspacing="0">
    > <tr>
    > <td>
    > <input type=submit value=Go> <span lang="en-gb"></span>
    > </form>
    > </td>
    > <td>
    > <form method="post" action="SelectBoxes.asp"><input type="submit"
    > value=" Reset " /></form></font>
    > </form>
    > </td>
    > </table>
    >
    > <font face="Arial" size="2">You can make as many changes as you require,
    > just select
    > <b>Go</b> again to update</font>
    >
    > <%
    > Sub GetSelectBoxes()
    >
    > if not oRS.EOF then
    > Dim sCurrentBox
    > Dim bIsFirst
    > bIsFirst=true
    >
    >
    > Dim mCurrentSelectedValue
    >
    > Do While not oRS.EOF
    > 'OK, we have our recordset.
    > 'Let's go through each "thingy" and create a box for
    > it.
    > if sCurrentBox <> oRS.Fields("Component_Type") then
    >
    > 'it's time for a new select box.
    > 'but first, let's close the last box.
    > if bIsFirst=false then
    > 'make sure it's not the first select box.
    > Response.Write "</select><br>" & vbCrLf
    > else
    > bIsFirst=false
    > end if
    >
    > 'Create a line space between each box
    > Response.Write ("<br>")
    > 'OK, create the new box.
    >
    > sCurrentBox=oRS.Fields("Component_Type")
    > mCurrentSelectedValue = Request.Form(sCurrentBox)
    >
    > Response.Write sCurrentBox & ": <select name=""" & sCurrentBox
    > & """>" & vbCrLf
    >
    > end if
    >
    > 'Now add the individual item
    > Response.Write vbTab & "<option value=""" & oRS.Fields
    > ("UniqueID") & """"
    >
    > If mCurrentSelectedValue <> "" Then
    > If mCurrentSelectedValue = CStr(trim(oRS.Fields
    > ("uniqueid"))) Then
    > Response.Write " selected "
    > End If
    > End If
    >
    > Response.Write ">" & trim(oRS.Fields("Component_Name")) & " :
    > " & " £" & trim(oRS.Fields("Price")) & "</option>" & vbCrLf
    >
    >
    > oRS.MoveNext
    >
    > Loop
    >
    > 'Let's close that last one
    > Response.Write "</select>" & vbCrLf
    >
    >
    > end if
    >
    > Set oRS=nothing
    > oCN.Close
    > Set oCN=nothing
    > End Sub
    >
    > %> </BODY>
    > </HTML>
    >
    >
    > ====================================================================
    > sendEMail2.asp page
    > ====================================================================
    >
    > <%
    > Option Explicit
    > Response.Expires = -10000
    > %>
    >
    >
    >
    > <%
    >
    > Dim mEMailBody
    >
    > Dim mComponentLoop
    > Dim mComponentCount
    >
    > mComponentCount = Request.Form("ComponentCount")
    >
    > Response.Write "This is the confirmation page.<br /><br />"
    >
    > mEMailBody = mEMailBody & "<table border='0' cellspacing='1'
    > cellpadding='1' width='400'>"
    > mEMailBody = mEMailBody & "<tr><td><b>Component</b></td><td
    > align='right'><b>£</b></td></tr>"
    >
    > For mComponentLoop = 1 to mComponentCount
    > mEMailBody = mEMailBody & "<tr>"
    > mEMailBody = mEMailBody & "<td>" & Request.Form("Component" &
    > mComponentLoop) & "</td>"
    > mEMailBody = mEMailBody & "<td align='right'>" & Request.Form
    > ("ComponentPrice" & mComponentLoop) & "</td>"
    > mEMailBody = mEMailBody & "</tr>"
    > Next
    >
    > mEMailBody = mEMailBody & "<tr><td align='right'><b>Total:</b></td><td>
    > £" & Request.Form("ComponentPriceTotal") & "</td></tr>"
    > mEMailBody = mEMailBody & "</table>"
    >
    > Response.Write mEMailBody
    >
    >
    > 'start email section
    >
    > Set JMail = Server.CreateObject ("JMail.SMTPMail")
    > JMail.ServerAddress = "hostserver.net" 'actual server address removed
    > JMail.Sender = Name
    > JMail.ReplyTo = Email
    > JMail.Subject = Subject
    > JMail.AddRecipient Recipient
    > JMail.Body = Name & Email & Tel & vbCrLf & BodyText
    > JMail.Priority = 3
    > JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
    > JMail.Execute
    >
    > Response.Redirect("formthanks.html")
    > Else
    > 'do nothing, just display blank form
    >
    > End IF
    > ODBCConnection.Close
    > Set ODBCConnection=Nothing
    >
    > Response.Write "<form method='post' action='SendEMail.asp'>"
    > Response.Write "Name:<input type='text' name='Name' value='' /><br />"
    > Response.Write "EMail Address:<input type='text' name='EMail' value='' />
    > <br />"
    > Response.Write "Tel No:<input type='text' name='Tel' value='' /><br />"
    > Response.Write "<input type=""hidden"" name=""Recipient""
    > value="""" /><br /> 'actual e-mail address removed
    > Response.Write "<input type=""hidden"" name=""BodyText"" value=""" &
    > mEMailBody & """ />"
    > Response.Write "<input type=""submit"" value="" Send EMail "" /><br />"
    > Response.Write "</form>"
    > %>
    grw, Nov 29, 2003
    #2
    1. Advertising

  3. Kingdom

    Kingdom Guest

    "grw" <> wrote in
    news:eibyy$:

    > IE > tools > options > advanced > DONT show friendly errors will give
    > the true problem
    >
    >

    I learn something new every day, thanks for that info.

    I got

    Microsoft VBScript compilation error '800a03ea'

    Syntax error

    /SendEMail2.asp, line 50

    Else
    ^
    Kingdom, Nov 30, 2003
    #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. Ron
    Replies:
    2
    Views:
    445
    Showjumper
    Jun 30, 2003
  2. Preston Crawford
    Replies:
    0
    Views:
    416
    Preston Crawford
    Feb 4, 2004
  3. Vix
    Replies:
    1
    Views:
    3,403
    Thomas Weidenfeller
    Jan 26, 2005
  4. Al

    Jmail problem

    Al, Mar 13, 2005, in forum: Java
    Replies:
    1
    Views:
    511
    GaryM
    Mar 14, 2005
  5. blair

    Sending mail with JMail question

    blair, Feb 16, 2004, in forum: ASP General
    Replies:
    0
    Views:
    125
    blair
    Feb 16, 2004
Loading...

Share This Page