472,117 Members | 2,672 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,117 software developers and data experts.

Converting CDONTS to CDO to send mail from a guestbook to me....

I have been running CDONTS in my ASPpages to send emails to me sent from my
guestbook. It had been working fine untill I upgraded to Server 2003 (I am
also running Exchange 2003) all locally. I will include the code I
originally used. I understand I should switch from CDONTS to CDO mail but
after several sttempts I am finding a very hard time getting the new CDO mail
to work properly. Any assistance with this would be greatly appreciated.
Here is the code:

------------------------------------------------------------------------------------------------

'Set the response buffer to true so we execute all asp code before sending
the HTML to the clients browser
Response.Buffer = True

'Dimension variables
Dim strBody 'Holds the body of the e-mail
Dim objCDOMail 'Holds the mail server object
Dim strMyEmailAddress 'Holds your e-mail address
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want
to send carbon copies of the e-mail
Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish
to send blind copies of the e-mail
Dim strReturnEmailAddress 'Holds the return e-mail address of the user
'----------------- Place your e-mail address in the following sting
-----------------------

strMyEmailAddress = "me@mailserver.com"

'----------- Place Carbon Copy e-mail address's in the following sting,
separated by ; --------------

strCCEmailAddress = "" 'Use this string only if you want to send the carbon
copies of the e-mail

'----------- Place Blind Copy e-mail address's in the following sting,
separated by ; --------------

strBCCEmailAddress = "" 'Use this string only if you want to send the blind
copies of the e-mail

'------------------------------------------------------------------------------------------------
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("email")
'Initialse strBody string with the body of the e-mail
strBody = "<h2>E-mail sent from form on Web Site</h2>"
strBody = strBody & "<br><b>Name: </b>" & Request.Form("firstName") & " " &
Request.Form("lastName")
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
strBody = strBody & "<br><br><b>Comments: - </b><br>" &
Replace(Request.Form("enquiry"), vbCrLf, "<br>")
'Check to see if the user has entered an e-mail address and that it is a
valid address otherwise set the e-mail address to
your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress)
< 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1,
strReturnEmailAddress, "@", 1)
< 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1,
strReturnEmailAddress, "@", 1) Then

'Set the return e-mail address to your own
strReturnEmailAddress = strMyEmailAddress
End If
'Send the e-mail

'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

'Who the e-mail is from (this needs to have an e-mail address in it for the
e-mail to be sent)
objCDOMail.From = Request.Form("firstName") & " " & Request.Form("lastName")
& " <" & strReturnEmailAddress & ">"

'Who the e-mail is sent to
objCDOMail.To = strMyEmailAddress

'Who the carbon copies are sent to
objCDOMail.Cc = strCCEmailAddress

'Who the blind copies are sent to
objCDOMail.Bcc = strBCCEmailAddress

'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0

'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0

'Set the subject of the e-mail
objCDOMail.Subject = "Guestbook Submission"

'Set the main body of the e-mail
objCDOMail.Body = strBody

'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1

'Send the e-mail
objCDOMail.Send

'Close the server object
Set objCDOMail = Nothing
%>
<html>
<head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>Thank you</title>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990099"
alink="#FF0000">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="2">
<h1 align="center">Success !! !! !!</h1>
</td>
</tr>
</table>
<br>
<br>
<table width="85%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><B><h3> Thank-you <% = Request.Form("firstName")
%>&nbsp;<% = Request.Form("lastName") %>
for signing our guestbook. </h3>
<br>
</td>
</tr>
</table>
------------------------------------------------------------------------------------------------

Not sure if this is necessary or not but this is the code from the guestbook
front page.....
------------------------------------------------------------------------------------------------

<!-- Javascript function to check the submitted form has been filled in
correctly before submitting -->
<SCRIPT language="JavaScript">
<!-- Hide from older browsers

//Check the enquiry form is filled in correctly
function CheckForm () {

//Initialise variables
var errorMsg = "";

//Check for a first name
if (document.frmEnquiry.firstName.value == ""){
errorMsg += "\n\tFirst Name \t- Enter your First Name";
}

//Check for a last name
if (document.frmEnquiry.lastName.value == ""){
errorMsg += "\n\tLast Name \t- Enter your Last Name";
}

//Check for an e-mail address and that it is valid
if ((document.frmEnquiry.email.value == "") ||
(document.frmEnquiry.email.value.length > 0 &&
(document.frmEnquiry.email.value.indexOf("@",0) == - 1 ||
document.frmEnquiry.email.value.indexOf(".",0) == - 1))) {
errorMsg += "\n\tE-mail Address \t- Enter your valid e-mail address";
}

//Check for an enquiry
if (document.frmEnquiry.enquiry.value == "") {
errorMsg += "\n\tComments \t\t- Enter comments please";
}

//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg = "_________________________________________________ _____________\n\n";
msg += "Your guestbook submition has not been sent because there are
problem(s) with the form.\n";
msg += "Please correct the problem(s) and re-submit the form.\n";
msg += "_________________________________________________ _____________\n\n";
msg += "The following field(s) need to be corrected: -\n";

errorMsg += alert(msg + errorMsg + "\n\n");
return false;
}

return true;
}
// -->
</script>
<!-- Close the HTML document head -->
</head>
<!-- Start the HTML body -->
' <body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990099"
alink="#FF0000">
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> <br>
<h1 align="center">Please sign our GuestBook</h1>
</td>
</tr>
</table>
<table width="85%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="90%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td>
<form method="post" name="frmEnquiry" action="thanks.asp"
onSubmit="return CheckForm();">
<table width="450" border="0" align="center" cellpadding="0"
cellspacing="0" >
<!-- First tabe row -->
<tr>
<td colspan="3"> <font size="2"> *Indicates required fields
</b></font>
</tr>

<!-- second table row -->

<tr>

<td width="265"><B>First Name* <br>
<input maxlength="30" name="firstName">
</td>
<!-- Coloum two in the second table row -->
<td width="185" colspan="2"><B>Last Name* <br>
<input maxlength="30" name="lastName">
</td>
</tr>
<!-- Third table row spread over 3 coloumns -->
<tr>
<td width="265"><B>E-mail Address* <br>
<input maxlength="255" name="email">
</td>
<td width="185" colspan="2"> </td>
</tr>
<td colspan="3" height="170"><B>Comments* <br>
<textarea name="enquiry" cols="50" rows="10"></textarea>
</td>
</tr>
<tr align="center">
<td colspan="3" height="36">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Clear Form">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
------------------------------------------------------------------------------------------------
Any help with this is greatly appreciated !!
Jul 29 '05 #1
6 10989
Hi Rick,

May I suggest that instead of posting all the lines in your file and saying
that you're having trouble getting something to work properly that you
instead explain to us what isn't working, what errors you're getting, what
unexpected results you're getting, and only post the relevant code?

Ray at work

"DigitalRick" <Di*********@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
I have been running CDONTS in my ASPpages to send emails to me sent from my guestbook. It had been working fine untill I upgraded to Server 2003 (I am also running Exchange 2003) all locally. I will include the code I
originally used. I understand I should switch from CDONTS to CDO mail but
after several sttempts I am finding a very hard time getting the new CDO mail to work properly. Any assistance with this would be greatly appreciated.
Here is the code:

Jul 29 '05 #2
Several working code samples here:
http://www.aspfaq.com/2026

Writing a simple one that works and then augmenting it would probably be an
easier approach than reverse engineering your existing code.


"DigitalRick" <Di*********@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
I have been running CDONTS in my ASPpages to send emails to me sent from
my
guestbook. It had been working fine untill I upgraded to Server 2003 (I
am
also running Exchange 2003) all locally. I will include the code I
originally used. I understand I should switch from CDONTS to CDO mail but
after several sttempts I am finding a very hard time getting the new CDO
mail
to work properly. Any assistance with this would be greatly appreciated.

Jul 29 '05 #3
As Aaron says see: > http://www.aspfaq.com/2026
make sure you read the part at the bottom about "80040222" or "80040220"
errors. there are security patches that block access to the metabase by the
anonymous user account.

--
--Mark Schupp
"DigitalRick" <Di*********@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
I have been running CDONTS in my ASPpages to send emails to me sent from
my
guestbook. It had been working fine untill I upgraded to Server 2003 (I
am
also running Exchange 2003) all locally. I will include the code I
originally used. I understand I should switch from CDONTS to CDO mail but
after several sttempts I am finding a very hard time getting the new CDO
mail
to work properly. Any assistance with this would be greatly appreciated.
Here is the code:

------------------------------------------------------------------------------------------------

'Set the response buffer to true so we execute all asp code before sending
the HTML to the clients browser
Response.Buffer = True

'Dimension variables
Dim strBody 'Holds the body of the e-mail
Dim objCDOMail 'Holds the mail server object
Dim strMyEmailAddress 'Holds your e-mail address
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want
to send carbon copies of the e-mail
Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish
to send blind copies of the e-mail
Dim strReturnEmailAddress 'Holds the return e-mail address of the user
'----------------- Place your e-mail address in the following sting
-----------------------

strMyEmailAddress = "me@mailserver.com"

'----------- Place Carbon Copy e-mail address's in the following sting,
separated by ; --------------

strCCEmailAddress = "" 'Use this string only if you want to send the
carbon
copies of the e-mail

'----------- Place Blind Copy e-mail address's in the following sting,
separated by ; --------------

strBCCEmailAddress = "" 'Use this string only if you want to send the
blind
copies of the e-mail

'------------------------------------------------------------------------------------------------
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("email")
'Initialse strBody string with the body of the e-mail
strBody = "<h2>E-mail sent from form on Web Site</h2>"
strBody = strBody & "<br><b>Name: </b>" & Request.Form("firstName") & " "
&
Request.Form("lastName")
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
strBody = strBody & "<br><br><b>Comments: - </b><br>" &
Replace(Request.Form("enquiry"), vbCrLf, "<br>")
'Check to see if the user has entered an e-mail address and that it is a
valid address otherwise set the e-mail address to
your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress)
< 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1,
strReturnEmailAddress, "@", 1)
< 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1,
strReturnEmailAddress, "@", 1) Then

'Set the return e-mail address to your own
strReturnEmailAddress = strMyEmailAddress
End If
'Send the e-mail

'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

'Who the e-mail is from (this needs to have an e-mail address in it for
the
e-mail to be sent)
objCDOMail.From = Request.Form("firstName") & " " &
Request.Form("lastName")
& " <" & strReturnEmailAddress & ">"

'Who the e-mail is sent to
objCDOMail.To = strMyEmailAddress

'Who the carbon copies are sent to
objCDOMail.Cc = strCCEmailAddress

'Who the blind copies are sent to
objCDOMail.Bcc = strBCCEmailAddress

'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0

'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0

'Set the subject of the e-mail
objCDOMail.Subject = "Guestbook Submission"

'Set the main body of the e-mail
objCDOMail.Body = strBody

'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1

'Send the e-mail
objCDOMail.Send

'Close the server object
Set objCDOMail = Nothing
%>
<html>
<head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>Thank you</title>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990099"
alink="#FF0000">
<table width="95%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td height="2">
<h1 align="center">Success !! !! !!</h1>
</td>
</tr>
</table>
<br>
<br>
<table width="85%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td align="center"><B><h3> Thank-you <% = Request.Form("firstName")
%>&nbsp;<% = Request.Form("lastName") %>
for signing our guestbook. </h3>
<br>
</td>
</tr>
</table>
------------------------------------------------------------------------------------------------

Not sure if this is necessary or not but this is the code from the
guestbook
front page.....
------------------------------------------------------------------------------------------------

<!-- Javascript function to check the submitted form has been filled in
correctly before submitting -->
<SCRIPT language="JavaScript">
<!-- Hide from older browsers

//Check the enquiry form is filled in correctly
function CheckForm () {

//Initialise variables
var errorMsg = "";

//Check for a first name
if (document.frmEnquiry.firstName.value == ""){
errorMsg += "\n\tFirst Name \t- Enter your First Name";
}

//Check for a last name
if (document.frmEnquiry.lastName.value == ""){
errorMsg += "\n\tLast Name \t- Enter your Last Name";
}

//Check for an e-mail address and that it is valid
if ((document.frmEnquiry.email.value == "") ||
(document.frmEnquiry.email.value.length > 0 &&
(document.frmEnquiry.email.value.indexOf("@",0) == - 1 ||
document.frmEnquiry.email.value.indexOf(".",0) == - 1))) {
errorMsg += "\n\tE-mail Address \t- Enter your valid e-mail address";
}

//Check for an enquiry
if (document.frmEnquiry.enquiry.value == "") {
errorMsg += "\n\tComments \t\t- Enter comments please";
}

//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg =
"_________________________________________________ _____________\n\n";
msg += "Your guestbook submition has not been sent because there are
problem(s) with the form.\n";
msg += "Please correct the problem(s) and re-submit the form.\n";
msg +=
"_________________________________________________ _____________\n\n";
msg += "The following field(s) need to be corrected: -\n";

errorMsg += alert(msg + errorMsg + "\n\n");
return false;
}

return true;
}
// -->
</script>
<!-- Close the HTML document head -->
</head>
<!-- Start the HTML body -->
' <body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990099"
alink="#FF0000">
<table width="95%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td> <br>
<h1 align="center">Please sign our GuestBook</h1>
</td>
</tr>
</table>
<table width="85%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td>
<table width="90%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td>
<form method="post" name="frmEnquiry" action="thanks.asp"
onSubmit="return CheckForm();">
<table width="450" border="0" align="center" cellpadding="0"
cellspacing="0" >
<!-- First tabe row -->
<tr>
<td colspan="3"> <font size="2"> *Indicates required
fields
</b></font>
</tr>

<!-- second table row -->

<tr>

<td width="265"><B>First Name* <br>
<input maxlength="30" name="firstName">
</td>
<!-- Coloum two in the second table row -->
<td width="185" colspan="2"><B>Last Name* <br>
<input maxlength="30" name="lastName">
</td>
</tr>
<!-- Third table row spread over 3 coloumns -->
<tr>
<td width="265"><B>E-mail Address* <br>
<input maxlength="255" name="email">
</td>
<td width="185" colspan="2"> </td>
</tr>
<td colspan="3" height="170"><B>Comments* <br>
<textarea name="enquiry" cols="50" rows="10"></textarea>
</td>
</tr>
<tr align="center">
<td colspan="3" height="36">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Clear Form">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</td>
</tr>
</table>
------------------------------------------------------------------------------------------------
Any help with this is greatly appreciated !!

Jul 29 '05 #4
Sorry, in my haste to include as much information as possible I left out the
most important part.

The exact error I am getting when you click "submit" is:

Microsoft VBScript runtime error "800a0046"
Permission denied
/sarah/thanks.asp, line 164

That lines appears to be pointing to objCDOMail.Send

Please let me know if I have left any other necessary imformation out.

Rick

"Ray Costanzo [MVP]" wrote:
Hi Rick,

May I suggest that instead of posting all the lines in your file and saying
that you're having trouble getting something to work properly that you
instead explain to us what isn't working, what errors you're getting, what
unexpected results you're getting, and only post the relevant code?

Ray at work

"DigitalRick" <Di*********@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
I have been running CDONTS in my ASPpages to send emails to me sent from

my
guestbook. It had been working fine untill I upgraded to Server 2003 (I

am
also running Exchange 2003) all locally. I will include the code I
originally used. I understand I should switch from CDONTS to CDO mail but
after several sttempts I am finding a very hard time getting the new CDO

mail
to work properly. Any assistance with this would be greatly appreciated.
Here is the code:


Jul 29 '05 #5
Got it working. Thank you VERY much for all the insight !!!

It was permissions under Exchsrv directory, I was working in the wrong
direstories all this time <argh !!!>

"Mark Schupp" wrote:
As Aaron says see: > http://www.aspfaq.com/2026
make sure you read the part at the bottom about "80040222" or "80040220"
errors. there are security patches that block access to the metabase by the
anonymous user account.

--
--Mark Schupp
"DigitalRick" <Di*********@discussions.microsoft.com> wrote in message
news:0F**********************************@microsof t.com...
I have been running CDONTS in my ASPpages to send emails to me sent from
my
guestbook. It had been working fine untill I upgraded to Server 2003 (I
am
also running Exchange 2003) all locally. I will include the code I
originally used. I understand I should switch from CDONTS to CDO mail but
after several sttempts I am finding a very hard time getting the new CDO
mail
to work properly. Any assistance with this would be greatly appreciated.
Here is the code:

------------------------------------------------------------------------------------------------

'Set the response buffer to true so we execute all asp code before sending
the HTML to the clients browser
Response.Buffer = True

'Dimension variables
Dim strBody 'Holds the body of the e-mail
Dim objCDOMail 'Holds the mail server object
Dim strMyEmailAddress 'Holds your e-mail address
Dim strCCEmailAddress 'Holds any carbon copy e-mail addresses if you want
to send carbon copies of the e-mail
Dim strBCCEmailAddress 'Holds any blind copy e-mail addresses if you wish
to send blind copies of the e-mail
Dim strReturnEmailAddress 'Holds the return e-mail address of the user
'----------------- Place your e-mail address in the following sting
-----------------------

strMyEmailAddress = "me@mailserver.com"

'----------- Place Carbon Copy e-mail address's in the following sting,
separated by ; --------------

strCCEmailAddress = "" 'Use this string only if you want to send the
carbon
copies of the e-mail

'----------- Place Blind Copy e-mail address's in the following sting,
separated by ; --------------

strBCCEmailAddress = "" 'Use this string only if you want to send the
blind
copies of the e-mail

'------------------------------------------------------------------------------------------------
'Read in the users e-mail address
strReturnEmailAddress = Request.Form("email")
'Initialse strBody string with the body of the e-mail
strBody = "<h2>E-mail sent from form on Web Site</h2>"
strBody = strBody & "<br><b>Name: </b>" & Request.Form("firstName") & " "
&
Request.Form("lastName")
strBody = strBody & "<br><b>E-mail: </b>" & strReturnEmailAddress
strBody = strBody & "<br><br><b>Comments: - </b><br>" &
Replace(Request.Form("enquiry"), vbCrLf, "<br>")
'Check to see if the user has entered an e-mail address and that it is a
valid address otherwise set the e-mail address to
your own otherwise the e-mail will be rejected
If Len(strReturnEmailAddress)
< 5 OR NOT Instr(1, strReturnEmailAddress, " ") = 0 OR InStr(1,
strReturnEmailAddress, "@", 1)
< 2 OR InStrRev(strReturnEmailAddress, ".") < InStr(1,
strReturnEmailAddress, "@", 1) Then

'Set the return e-mail address to your own
strReturnEmailAddress = strMyEmailAddress
End If
'Send the e-mail

'Create the e-mail server object
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")

'Who the e-mail is from (this needs to have an e-mail address in it for
the
e-mail to be sent)
objCDOMail.From = Request.Form("firstName") & " " &
Request.Form("lastName")
& " <" & strReturnEmailAddress & ">"

'Who the e-mail is sent to
objCDOMail.To = strMyEmailAddress

'Who the carbon copies are sent to
objCDOMail.Cc = strCCEmailAddress

'Who the blind copies are sent to
objCDOMail.Bcc = strBCCEmailAddress

'Set the e-mail body format (0=HTML 1=Text)
objCDOMail.BodyFormat = 0

'Set the mail format (0=MIME 1=Text)
objCDOMail.MailFormat = 0

'Set the subject of the e-mail
objCDOMail.Subject = "Guestbook Submission"

'Set the main body of the e-mail
objCDOMail.Body = strBody

'Importance of the e-mail (0=Low, 1=Normal, 2=High)
objCDOMail.Importance = 1

'Send the e-mail
objCDOMail.Send

'Close the server object
Set objCDOMail = Nothing
%>
<html>
<head>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>Thank you</title>
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990099"
alink="#FF0000">
<table width="95%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td height="2">
<h1 align="center">Success !! !! !!</h1>
</td>
</tr>
</table>
<br>
<br>
<table width="85%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td align="center"><B><h3> Thank-you <% = Request.Form("firstName")
%> <% = Request.Form("lastName") %>
for signing our guestbook. </h3>
<br>
</td>
</tr>
</table>
------------------------------------------------------------------------------------------------

Not sure if this is necessary or not but this is the code from the
guestbook
front page.....
------------------------------------------------------------------------------------------------

<!-- Javascript function to check the submitted form has been filled in
correctly before submitting -->
<SCRIPT language="JavaScript">
<!-- Hide from older browsers

//Check the enquiry form is filled in correctly
function CheckForm () {

//Initialise variables
var errorMsg = "";

//Check for a first name
if (document.frmEnquiry.firstName.value == ""){
errorMsg += "\n\tFirst Name \t- Enter your First Name";
}

//Check for a last name
if (document.frmEnquiry.lastName.value == ""){
errorMsg += "\n\tLast Name \t- Enter your Last Name";
}

//Check for an e-mail address and that it is valid
if ((document.frmEnquiry.email.value == "") ||
(document.frmEnquiry.email.value.length > 0 &&
(document.frmEnquiry.email.value.indexOf("@",0) == - 1 ||
document.frmEnquiry.email.value.indexOf(".",0) == - 1))) {
errorMsg += "\n\tE-mail Address \t- Enter your valid e-mail address";
}

//Check for an enquiry
if (document.frmEnquiry.enquiry.value == "") {
errorMsg += "\n\tComments \t\t- Enter comments please";
}

//If there is aproblem with the form then display an error
if (errorMsg != ""){
msg =
"_________________________________________________ _____________\n\n";
msg += "Your guestbook submition has not been sent because there are
problem(s) with the form.\n";
msg += "Please correct the problem(s) and re-submit the form.\n";
msg +=
"_________________________________________________ _____________\n\n";
msg += "The following field(s) need to be corrected: -\n";

errorMsg += alert(msg + errorMsg + "\n\n");
return false;
}

return true;
}
// -->
</script>
<!-- Close the HTML document head -->
</head>
<!-- Start the HTML body -->
' <body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#990099"
alink="#FF0000">
<table width="95%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td> <br>
<h1 align="center">Please sign our GuestBook</h1>
</td>
</tr>
</table>
<table width="85%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td>
<table width="90%" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td>
<form method="post" name="frmEnquiry" action="thanks.asp"
onSubmit="return CheckForm();">
<table width="450" border="0" align="center" cellpadding="0"
cellspacing="0" >
<!-- First tabe row -->
<tr>
<td colspan="3"> <font size="2"> *Indicates required
fields
</b></font>
</tr>

<!-- second table row -->

<tr>

<td width="265"><B>First Name* <br>
<input maxlength="30" name="firstName">
</td>
<!-- Coloum two in the second table row -->
<td width="185" colspan="2"><B>Last Name* <br>
<input maxlength="30" name="lastName">
</td>
</tr>
<!-- Third table row spread over 3 coloumns -->
<tr>
<td width="265"><B>E-mail Address* <br>
<input maxlength="255" name="email">
</td>
<td width="185" colspan="2"> </td>
</tr>
<td colspan="3" height="170"><B>Comments* <br>
<textarea name="enquiry" cols="50" rows="10">

Jul 29 '05 #6
That should suffice. Your server probably has a directory,
C:\Inetpub\mailroot\pickup. When the CDO object executes its send method,
it's trying to write a file to that directory (the .msg file). If the
account running the script, typically IUSR_machine-name in a Web site,
doesn't have permission to write to that directory, you will get this
permission denied directory. So, try giving that user permission to write
to that directory.

Ray at work

"DigitalRick" <Di*********@discussions.microsoft.com> wrote in message
news:B8**********************************@microsof t.com...
Sorry, in my haste to include as much information as possible I left out the most important part.

The exact error I am getting when you click "submit" is:

Microsoft VBScript runtime error "800a0046"
Permission denied
/sarah/thanks.asp, line 164

That lines appears to be pointing to objCDOMail.Send

Please let me know if I have left any other necessary imformation out.

Rick

Jul 29 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Mario Leduc | last post: by
5 posts views Thread by tom | last post: by
1 post views Thread by Stimp | last post: by
4 posts views Thread by Dr. Harvey Waxman | last post: by
7 posts views Thread by Paul | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.