Forms, Datbase and Email & CDONTS

  • Thread starter Thread starter Glenn
  • Start date Start date
G

Glenn

I am using the white paper from microsoft on how to send form data to a
database and to email it.

I'm not having much success. I've tried it in both Front Page XP & 2003.

Here's what happens:

When I follow the directions to create the email.asp page and copy the code
out of the white paper, and click paste special / treat as HTML, it seems to
only insert part of the code.

When I complete the instructions, I try it and get an error:

Thank you for submitting your information!
You will receive an e-mail shortly. The e-mail was sent using the following
information:

Sent To:
From : Microsoft PSS Sample Page


Subject: Send to Database and E-mail

Content:

Microsoft VBScript runtime error '800a000d'

Type mismatch: 'ParseBody'

/lane/Email.asp, line 28


However, if I do it a little different, and before I paste the code I switch
into "code" or "html" (depending on FP version), then when I view the web
page it had a different color background, looks different, etc.

But, I still get an error. This time the error is "The Page Cannont Be
Displayed" ..... http 500 Internal Server Error.

I'm guessing my second approach is the correct one, but I'm not sure why I'm
getting the error.

Any suggestions?
 
Chapter 11 Helped me out with the basic and explained in details. Then I add
more form fields. I looked at how the string matched the form field and
corresponded. It was really easy.
 
I've narrowed my problem down. It is definitely the e-mail portion using
CDONTS that isn't working. When I take that section of the code out,
everything works fine - the data goes to the database, etc.

When I try having just the CDONTS code in to send to e-mail, I get the page
can't be found message.

Any suggestions?

I did buy the book you mentioned last night.
 
If your site is hosted on a Windows 2003 server, then CDONTS is not available unless the web host
has installed it from Windows 2000 server. Under Windows 2003 you would use CDOYSYS instead, which
is also available on Windows 2000 server. The coding for this is different from CDONTS. You can find
code sample by typing the following into the IE address bar:

? ASP Sending Mail with CDOSYS

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
Sure, here it is: (note that I changed my email to (e-mail address removed) in this posting
to avoid spam. In the actual code I have my real e-mail). I am sort of
wondering if this problem could be because I am running an exchange server
(2000) on my windows 2000 server, and in IIS there is no Default SMTP server
listed (though I have one in Exchange).



'===================================================================
' Send the results to e-mail.
' Use CDONTS to create and send a message based on information
' entered into the form. The following lines compose and send
' the e-mail.
'===================================================================

'====================================================================
' Set up variables:
' myCDONTSMail = A CDONTS mail object.
' strFrom = A string containing the source e-mail address.
' strTo = A string containing the destination e-mail address.
' strSubject = A string containing the subject of the e-mail.
' strBody = A string containing the body of the e-mail.
'====================================================================
Dim myCDONTSMail
Dim strFrom
Dim strTo
Dim strSubject
Dim strBody

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Assign the source e-mail address. Change this to your e-mail
' address.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strFrom="(e-mail address removed)"

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Assign the destination e-mail address. In this example, get the
' e-mail address from the form field called "EMail".
' You can customize this by removing the EMail form field and
' changing the following line to this:
' strTo="(e-mail address removed)" ? Change this to your e-mail
' address.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strTo=Request.Form("EMail")

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' The following line is the subject of the e-mail. You can change
' this to a subject that is customized to your liking.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strSubject = "Send to E-mail and Database"

'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' The following lines create the body of the message. This can be
' anything you want it to be.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
strBody="The following information was submitted:" & Chr(13)
strBody = strBody & Request.Form("FirstName") & " "
strBody = strBody & Request.Form("LastName")
strBody = strBody & Chr(13) & Request.Form("Address") & Chr(13)
strBody = strBody & Request.Form("City") & Chr(13)
strBody = strBody & Request.Form("Region") & Chr(13)
strBody = strBody & Request.Form("PostalCode") & Chr(13)
strBody = strBody & Chr(13) & "Thank you for submitting your data."

'====================================================================
' The SET statement creates the CDONTS mail object in preparation
' for sending the e-mail message.
'====================================================================
Set myCDONTSMail = CreateObject("CDONTS.NewMail")

'====================================================================
' The following line sends the mail message using the source e-mail,
' destination e-mail, subject, and body that were defined earlier.
'====================================================================
myCDONTSMail.Send strFrom,strTo,strSubject,strBody

'=== Set the CDONTS mail object to NOTHING to free resources.
Set myCDONTSMail = Nothing


'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' For information about how to customize the rest of this page, see the
' Customizing the Confirmation Page section of this document. Sections
' that are discussed in the Customizations section are delimited
' by percent signs.
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%>
 
I am using a Windows 2000 Server
Thomas A. Rowe said:
If your site is hosted on a Windows 2003 server, then CDONTS is not
available unless the web host has installed it from Windows 2000 server.
Under Windows 2003 you would use CDOYSYS instead, which is also available
on Windows 2000 server. The coding for this is different from CDONTS. You
can find code sample by typing the following into the IE address bar:

? ASP Sending Mail with CDOSYS

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
Since you are using Exchange Server, you might want to post to the Exchange newsgroup.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle, MS KB Quick Links, etc.
==============================================
 
The only thin I don't see in your script is the form action
<FORM ACTION="<%=Request.ServerVariables("SCRIPT_NAME")%>" METHOD=POST>

Then also after the form
</FORM>

<% End If %>

or this option at the top of your script
<%

if Request.Querystring("isSubmitted") = "yes" then


Then the form needs to have this action in
<form action="confirm.asp" method="get" name="Input_Form">

First Name:

<input type="text" size="30"

maxlength="50" name="First_Name">

<br>

Last Name:

<input type="text" size="30"

maxlength="50" name="Last_Name">

<br>

<input type="hidden" name="isSubmitted" value="yes">

<input type="submit" value="Submit Form">

</form>

This part of the form is important to give the
(Request.Querystring("isSubmitted")) the value of less to process.

<input type="hidden" name="isSubmitted" value="yes">

<input type="submit" value="Submit Form">
I hope this helps. I run Windows 2000 Server and CDONTS work for me.
 
Back
Top