|
 |
asp_cdo thread: CDONTS and Email help for newbie!
Message #1 by "kevin w perry" <kperry@c...> on Fri, 23 Feb 2001 20:17:59
|
|
Below is the code I used to have an HTML form page post my emailform.asp
but for some reason I get the following error?
/-------------------------------------------------
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/webdemoEmail_Form.asp, line 50
Invalid class string
/---------------------------------------------------
I use the CDONTS command but not sure what or why I am getting errors,
could some one please explain this in a baby step fashion on what I am
doing wrong?
Below is the code for the emailform.asp
/------------------
<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<title>webDemoFormEmail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
Dim Name, SendTo, EMail, Products, comments, phone, fax, Time, demoDate,
Priority
' Retrieve contents of EmailAddress field and remove blank spaces
' with the Trim method
Name = Trim(Request.Form("Name"))
' Set the email address that the message must be posted to.
SendTo = "kperry@c..."
' Retrieve contents of Message field and remove blank spaces with the Trim
method
EMail = Trim(Request.Form("EMail"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
Products = Trim(Request.Form("Products"))
' Retrieve contents of Subject field and remove blank spaces with the Trim
method
comments = Trim(Request.Form("comments"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
Phone = Trim(Request.Form("Phone"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
fax = Trim(Request.Form("fax"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
Time = Trim(Request.Form("Time"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
demoDate = Trim(Request.Form("demoDate"))
'Sets the priority of the message
Priority = 1
' Test if the From and Message variable are not blank
If (Name <> "" And EMail <> "") Then
' Create an instance of the CDONTS.NewMail object
Set Email = Server.CreateObject("CDONTS.NewMail")
' Send the email message by passing properties for the NewMail object
' directly to the Send method
Email.Send Name, EMail, Products, comments, phone, fax, time,demoDate,
Priority, SendTo, Priority
' Destroy the NewMail object
Set Email = Nothing
' Acknowledge that email has been sent
Response.Write "Thanks for the valuable feedback."
' The code within the Else statement will only be executed
' when the user has left both the email and Message fields blank
Else
' Advise user of why the email can't be sent
Response.Write "You have not completed all of the required details."
End If
%>
<p align="center"> </p>
<p> </p>
<p>
</p>
</body>
</html>
Message #2 by "Jonothon Ortiz" <jon@x...> on Fri, 23 Feb 2001 15:59:28 -0500
|
|
Almost forgot the obvious; apart from the code errors check to make sure
your server has CDONTS.DLL and everything it needs installed properly.
Jonothon Ortiz
Senior Web Developer
Xnext, Inc.
Ph: xxx.xxx.xxxx
or 888.84.XNEXT
http://www.Xnext.com
mailto:jon@x...
-----Original Message-----
From: kevin w perry [mailto:kperry@c...]
Sent: Friday, February 23, 2001 11:57 PM
To: ASP CDO
Subject: [asp_cdo] CDONTS and Email help for newbie!
Below is the code I used to have an HTML form page post my emailform.asp
but for some reason I get the following error?
/-------------------------------------------------
Server object error 'ASP 0177 : 800401f3'
Server.CreateObject Failed
/webdemoEmail_Form.asp, line 50
Invalid class string
/---------------------------------------------------
I use the CDONTS command but not sure what or why I am getting errors,
could some one please explain this in a baby step fashion on what I am
doing wrong?
Below is the code for the emailform.asp
/------------------
<%@LANGUAGE="VBSCRIPT"%>
<html>
<head>
<title>webDemoFormEmail</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<%
Dim Name, SendTo, EMail, Products, comments, phone, fax, Time, demoDate,
Priority
' Retrieve contents of EmailAddress field and remove blank spaces
' with the Trim method
Name = Trim(Request.Form("Name"))
' Set the email address that the message must be posted to.
SendTo = "kperry@c..."
' Retrieve contents of Message field and remove blank spaces with the Trim
method
EMail = Trim(Request.Form("EMail"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
Products = Trim(Request.Form("Products"))
' Retrieve contents of Subject field and remove blank spaces with the Trim
method
comments = Trim(Request.Form("comments"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
Phone = Trim(Request.Form("Phone"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
fax = Trim(Request.Form("fax"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
Time = Trim(Request.Form("Time"))
' Retrieve contents of Message field and remove blank spaces with the Trim
method
demoDate = Trim(Request.Form("demoDate"))
'Sets the priority of the message
Priority = 1
' Test if the From and Message variable are not blank
If (Name <> "" And EMail <> "") Then
' Create an instance of the CDONTS.NewMail object
Set Email = Server.CreateObject("CDONTS.NewMail")
' Send the email message by passing properties for the NewMail object
' directly to the Send method
Email.Send Name, EMail, Products, comments, phone, fax, time,demoDate,
Priority, SendTo, Priority
' Destroy the NewMail object
Set Email = Nothing
' Acknowledge that email has been sent
Response.Write "Thanks for the valuable feedback."
' The code within the Else statement will only be executed
' when the user has left both the email and Message fields blank
Else
' Advise user of why the email can't be sent
Response.Write "You have not completed all of the required details."
End If
%>
<p align="center"> </p>
<p> </p>
<p>
</p>
</body>
</html>
Message #3 by "Jonothon Ortiz" <Jon@x...> on Mon, 26 Feb 2001 18:47:13
|
|
crap..my first reply didn't show up - here it is
*this may be a resend; i had an error with the original mail
see the CDONTS reference on MSDN about how to use it.
http://msdn.microsoft.com/library/psdk/cdo/_denali_newmail_object_cdonts_li
brary_.htm
some quick notes about your code while I was skimming through it:
This line, in particular:
*Email.Send Name, EMail, Products, comments, phone, fax, time,demoDate,
Priority, SendTo, Priority*
The SEND method of CDONTS.NewMail
1. Doesn't allow for multiple recepients
2. Doesn't send the body (message) of the email
You're also missing (apparently) the FROM method - this is required
you may want to try this:
Email.Send = Name & "<" & EMail &">"
Email.From = "from whatever email address"
Email.To = "to whatever email address
Email.Body = Products & VBCRLF & ... etc, etc.
whenever you want to include multiple strings, use the & and seperate each
one by a VBCRLF; in this case, it looks like you're using this as for a
FORM. Dont' forget to replace the "from whatever..." and "to whatever..."
with the correct email addresses.
ohyeah, if you want to keep little spammer kids from using your script to
send out their mail, hardcode the email address for the "to" inside your
script. furthermore, use the METHOD = POST to keep people from seeing your
query string.
finally, anytime you try a new method, object, or function make sure you
read up on it first to avoid errors. it can be a bit daunting, but you'll
eliminate simple errors like this from the get-go =)
eh..funny thing; I was troubleshooting a CDONTS error just today...LOL
> Below is the code I used to have an HTML form page post my emailform.asp
> but for some reason I get the following error?
> /-------------------------------------------------
> Server object error 'ASP 0177 : 800401f3'
>
> Server.CreateObject Failed
>
> /webdemoEmail_Form.asp, line 50
>
> Invalid class string
> /---------------------------------------------------
>
> I use the CDONTS command but not sure what or why I am getting errors,
> could some one please explain this in a baby step fashion on what I am
> doing wrong?
>
> Below is the code for the emailform.asp
> /------------------
> <%@LANGUAGE="VBSCRIPT"%>
>
> <html>
> <head>
> <title>webDemoFormEmail</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
>
> </head>
>
> <body bgcolor="#FFFFFF" text="#000000">
> <%
>
> Dim Name, SendTo, EMail, Products, comments, phone, fax, Time, demoDate,
> Priority
>
> ' Retrieve contents of EmailAddress field and remove blank spaces
> ' with the Trim method
> Name = Trim(Request.Form("Name"))
>
> ' Set the email address that the message must be posted to.
> SendTo = "kperry@c..."
>
> ' Retrieve contents of Message field and remove blank spaces with the
Trim
> method
> EMail = Trim(Request.Form("EMail"))
>
> ' Retrieve contents of Message field and remove blank spaces with the
Trim
> method
> Products = Trim(Request.Form("Products"))
>
> ' Retrieve contents of Subject field and remove blank spaces with the
Trim
> method
> comments = Trim(Request.Form("comments"))
>
> ' Retrieve contents of Message field and remove blank spaces with the
Trim
> method
> Phone = Trim(Request.Form("Phone"))
>
> ' Retrieve contents of Message field and remove blank spaces with the
Trim
> method
> fax = Trim(Request.Form("fax"))
>
> ' Retrieve contents of Message field and remove blank spaces with the
Trim
> method
> Time = Trim(Request.Form("Time"))
>
> ' Retrieve contents of Message field and remove blank spaces with the
Trim
> method
> demoDate = Trim(Request.Form("demoDate"))
>
> 'Sets the priority of the message
> Priority = 1
>
> ' Test if the From and Message variable are not blank
> If (Name <> "" And EMail <> "") Then
>
> ' Create an instance of the CDONTS.NewMail object
> Set Email = Server.CreateObject("CDONTS.NewMail")
>
> ' Send the email message by passing properties for the NewMail object
> ' directly to the Send method
> Email.Send Name, EMail, Products, comments, phone, fax, time,demoDate,
> Priority, SendTo, Priority
>
> ' Destroy the NewMail object
> Set Email = Nothing
>
> ' Acknowledge that email has been sent
> Response.Write "Thanks for the valuable feedback."
>
> ' The code within the Else statement will only be executed
> ' when the user has left both the email and Message fields blank
> Else
>
> ' Advise user of why the email can't be sent
> Response.Write "You have not completed all of the required details."
>
> End If
>
> %>
> <p align="center"> </p>
> <p> </p>
> <p>
> </p>
> </body>
> </html>
>
|
|
 |