It is possible to do both, the problem is the script itself.
First, it's going to run each and every time as there is no condition to
check if it's the user is submitting a form or refreshing a page.
You can do the same thing the FP database code does and add an If Then
statement to check for the condition that a post has occured. You can do
this by adding the following before the beginning of the CDO code:
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
and then add an End If after the code.
Next, change the following two lines from this:
TextBody = TextBody & "Name " & Request("Name").Item & VbCrLf
TextBody = TextBody & "Department " & Request("Department").Item &
VbCrLf
into this:
TextBody = TextBody & "Name " & Request.Form("Name") & VbCrLf
TextBody = TextBody & "Department " & Request.Form("Department") &
VbCrLf
This code should do better as it's pointing directly to the collection of
form field variables. When a Request(somefieldname) is done, it will search
each collection of possible request variables, Form, QueryString, and
ServerVariables to find what it wants. This is both a huge performance hit
and problematic for returning results.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"SS" <(E-Mail Removed)> wrote in message
news:ebuh1a$ui6$(E-Mail Removed)...
> Hi
>
> I have now discovered that the following code sends a mail as soon as it
> is
> executed which would explain why no information is in the mail. Once the
> form is filled in and the submit button hit the result is the same only
> the
> field names Name and Department appear in the mail the same as the first
> mail. I'm starting think that CDO and Frontpage forms to a database are
> not
> possible but would be great if anyone can tell me differently!
>
> <%
> ' FP_ASP ASP Automatically generated by a FrontPage Component. Do not
> Edit.
>
> On Error Resume Next
> Session("FP_OldCodePage") = Session.CodePage
> Session("FP_OldLCID") = Session.LCID
> Session.CodePage = 1252
> Err.Clear
>
> strErrorUrl = ""
>
> If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
> If Request.Form("VTI-GROUP") = "0" Then
> Err.Clear
>
> Set fp_conn = Server.CreateObject("ADODB.Connection")
> FP_DumpError strErrorUrl, "Cannot create connection"
>
> Set fp_rs = Server.CreateObject("ADODB.Recordset")
> FP_DumpError strErrorUrl, "Cannot create record set"
>
> fp_conn.Open Application("name_ConnectionString")
> FP_DumpError strErrorUrl, "Cannot open database"
>
> fp_rs.Open "Results", fp_conn, 1, 3, 2 ' adOpenKeySet, adLockOptimistic,
> adCmdTable
> FP_DumpError strErrorUrl, "Cannot open record set"
>
> fp_rs.AddNew
> FP_DumpError strErrorUrl, "Cannot add new record set to the database"
> Dim arFormFields0(2)
> Dim arFormDBFields0(2)
> Dim arFormValues0(2)
>
> arFormFields0(0) = "Department"
> arFormDBFields0(0) = "Department"
> arFormValues0(0) = Request("Department")
> arFormFields0(1) = "Name"
> arFormDBFields0(1) = "Name"
> arFormValues0(1) = Request("Name")
>
> FP_SaveFormFields fp_rs, arFormFields0, arFormDBFields0
>
> FP_SaveFieldToDB fp_rs, Now, "Timestamp"
>
> fp_rs.Update
> FP_DumpError strErrorUrl, "Cannot update the database"
>
> fp_rs.Close
> fp_conn.Close
>
> FP_FormConfirmation "text/html; charset=windows-1252",_
> "Form Confirmation",_
> "Thank you for submitting the following information:",_
> "cdoscript.asp",_
> "Return to the form."
>
> End If
> End If
>
> Session.CodePage = Session("FP_OldCodePage")
> Session.LCID = Session("FP_OldLCID")
>
> %>
> <html>
>
> <head>
> <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
> <meta name="ProgId" content="FrontPage.Editor.Document">
> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
> <title>Software Requirements Form</title>
> </head>
>
> <body>
> <!--
> METADATA
> TYPE="typelib"
> UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
> NAME="CDO for Windows 2000 Library"
> -->
>
> <%
>
>
> Dim TextBody
> Dim Name
> Dim Department
>
> Set cdoConfig = CreateObject("CDO.Configuration")
>
> TextBody = TextBody & "Name " & Request("Name").Item & VbCrLf
> TextBody = TextBody & "Department " & Request("Department").Item & VbCrLf
>
>
>
>
> With cdoConfig.Fields
> .Item(cdoSendUsingMethod) = cdoSendUsingPort
> .Item(cdoSMTPServer) = "my.server.com"
> .Update
> End With
>
> Dim objMail
> 'Create the mail object
> Set objMail = Server.CreateObject("CDO.Message")
> 'Set key properties
> objMail.From = "(E-Mail Removed)"
> objMail.To = "(E-Mail Removed)"
> objMail.Subject = "Software Required"
> objMail.TextBody = TextBody
>
>
> objMail.Send
>
>
> Set cdoMessage = Nothing
> Set cdoConfig = Nothing
>
> %>
>
>
>
> <p align="center"><b><font size="6" face="Arial">Software Requirements
> Form</font></b><p> </p>
> <p> </p>
> <form method="POST" action="--WEBBOT-SELF--">
> <!--webbot bot="SaveDatabase" SuggestedExt="asp" S-DataConnection="name"
> S-RecordSource="Results" U-Database-URL="../fpdb/name.mdb"
> S-Form-Fields="Department Name" S-Form-DBFields="Department Name"
> S-Builtin-Fields="Timestamp" S-Builtin-DBFields="Timestamp" startspan
> U-ASP-Include-Url="../_fpclass/fpdbform.inc" --><input TYPE="hidden"
> NAME="VTI-GROUP" VALUE="0"><!--#include
> file="../_fpclass/fpdbform.inc"--><!--webbot bot="SaveDatabase" endspan
> i-checksum="34604" -->
>
> <table CELLSPACING="0" CELLPADDING="0" BORDER="0" WIDTH="530" id="table1">
> <tr>
> <td WIDTH="180" valign="top"><font face="Arial">Name</font></td>
> <td WIDTH="350" colspan="3">
> <input type="text" name="Name" size="20"></td>
> </tr>
> <tr>
> <td WIDTH="180" valign="top"> </td>
> <td WIDTH="80"> </td>
> <td WIDTH="10"> </td>
> <td WIDTH="80"> </td>
> </tr>
> <tr>
> <td WIDTH="180" valign="top">Department</td>
> <td WIDTH="350" colspan="3">
> <input type="text" name="Department" size="20"></td>
> </tr>
> </table>
>
> <p> &
> nbsp;  
> ; &nb
> sp; <input type="submit" value="Submit"
> name="B1"></p>
> </form>
>
> </body>
>
> </html>
>
>
|