Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP 500 Error

Status
Not open for further replies.

ScottTN

IS-IT--Management
Sep 19, 2002
22
US
When trying to use to code below, I recieve a 500 error. The error occurs on the objMail.Send line.

Any ideas?

intIndex = instr(txtEMail,"@")
if intIndex then
if instr(intIndex + 1,txtEMail,".") then
strMsg = "Dear " & txtFName & " " & txtLName & "," & vbcrlf
strMsg = strMsg + "Your lead has been submitted to RHGS."
strMsg = strMsg + " If you have requested to be contacted, someone will be in touch with you shortly."
strMsg = strMsg + " Please look over the following list for errors. If you did make an error, please resubmit the request form and type update in the comments field."
strMsg = strMsg + vbcrlf & vbcrlf + "Submission Results:" & vbcrlf & vbcrlf
strMsg = strMsg + "First Name:" & " " & txtFName & vbcrlf
strMsg = strMsg + "Last Name:" & " " & txtLName & vbcrlf
strMsg = strMsg + "Company:" & " " & txtCName & vbcrlf
strMsg = strMsg + "Email Address:" & " " & txtEmail & vbcrlf & vbcrlf
strMsg = strMsg + "Phone:" & " " & txtPhone & vbcrlf & vbcrlf
strMsg = strMsg + "Fax:" & " " & txtFax & vbcrlf & vbcrlf
strMsg = strMsg + "Address:" & " " & txtAddress & vbcrlf & vbcrlf
strMsg = strMsg + "City:" & " " & txtCity & vbcrlf & vbcrlf
strMsg = strMsg + "Zip Code:" & " " & txtZipCode & vbcrlf & vbcrlf
strMsg = strMsg + "Comments:" & " " & txtComments & vbcrlf & vbcrlf
strMsg = strMsg + "Submitter Name:" & " " & txtSName & vbcrlf & vbcrlf
strMsg = strMsg + "Submitter Location:" & " " & txtSLocation & vbcrlf & vbcrlf
strMsg = strMsg + "Submitter Phone:" & " " & txtSPhone & vbcrlf & vbcrlf
' strMsg = strMsg + "Contact Requested:" & " " & txtContact & vbcrlf & vbcrlf

end if

strMsg = strMsg & vbcrlf & vbcrlf
strMsg = strMsg & "Sincerely," & vbcrlf
strMsg = strMsg & "Rural Health Group Services" & vbcrlf


set objMail = CreateObject("CDONTS.Newmail")
objMail.From = "address@domain.com"
objMail.To = txtEMail
objMail.Subject = "RHGS Lead from the Web"
objMail.Body = strMsg
objMail.Send
set objMail = nothing
set strMsg = nothing

end if
 
Well, first,
this line:
Code:
if intIndex then
is dangerous. the function InStr returns the index in the string where your second string starts, not a boolean value.
Same with your second if statement.

Third, if you are not using javascript for your language, than you need to replace all of those + signs with &'s, as the & is the concatenation charactr for vbScript, not the +.

If you are using javascript, than you need to check your methods your calling, to my knowledge InStr doesn't exist for javascript.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
Here is the full code maybe this will help. The email server is an exchange server setup to allow internal relays.

<%@ Language=VBScript %>
<%
<!--#include file=&quot;cdovbs.inc&quot;-->


' Get the Contact information used more than once

txtFName = Request.Form(&quot;fname&quot;)
txtLName = Request.Form(&quot;lname&quot;)
txtCName = Request.Form(&quot;cname&quot;)
txtEmployees = Request.Form(&quot;employees&quot;)
txtEmail = Request.Form(&quot;email&quot;)
txtPhone = Request.Form(&quot;phone&quot;)
txtFax = Request.Form(&quot;fax&quot;)
txtAddress = Request.Form(&quot;address&quot;)
txtCity = Request.Form(&quot;city&quot;)
txtZipCode = Request.Form(&quot;zipcode&quot;)
txtComments = Request.Form(&quot;comments&quot;)
txtSName = Request.Form(&quot;sname&quot;)
txtSLocation = Request.Form(&quot;slocation&quot;)
txtSPhone = Request.Form(&quot;sphone&quot;)
' txtContact = Request.Form(&quot;contact&quot;)

' ***********************************
' Now email the user a acknowledgment
' ***********************************

intIndex = instr(txtEMail,&quot;@&quot;)
if intIndex then
if instr(intIndex + 1,txtEMail,&quot;.&quot;) then
strMsg = &quot;Dear &quot; & txtFName & &quot; &quot; & txtLName & &quot;,&quot; & vbcrlf
strMsg = strMsg + &quot;Your lead has been submitted to RHGS.&quot;
strMsg = strMsg + &quot; If you have requested to be contacted, someone will be in touch with you shortly.&quot;
strMsg = strMsg + &quot; Please look over the following list for errors. If you did make an error, please resubmit the request form and type update in the comments field.&quot;
strMsg = strMsg + vbcrlf & vbcrlf + &quot;Submission Results:&quot; & vbcrlf & vbcrlf
strMsg = strMsg + &quot;First Name:&quot; & &quot; &quot; & txtFName & vbcrlf
strMsg = strMsg + &quot;Last Name:&quot; & &quot; &quot; & txtLName & vbcrlf
strMsg = strMsg + &quot;Company:&quot; & &quot; &quot; & txtCName & vbcrlf
strMsg = strMsg + &quot;Email Address:&quot; & &quot; &quot; & txtEmail & vbcrlf & vbcrlf
strMsg = strMsg + &quot;Phone:&quot; & &quot; &quot; & txtPhone & vbcrlf & vbcrlf
strMsg = strMsg + &quot;Fax:&quot; & &quot; &quot; & txtFax & vbcrlf & vbcrlf
strMsg = strMsg + &quot;Address:&quot; & &quot; &quot; & txtAddress & vbcrlf & vbcrlf
strMsg = strMsg + &quot;City:&quot; & &quot; &quot; & txtCity & vbcrlf & vbcrlf
strMsg = strMsg + &quot;Zip Code:&quot; & &quot; &quot; & txtZipCode & vbcrlf & vbcrlf
strMsg = strMsg + &quot;Comments:&quot; & &quot; &quot; & txtComments & vbcrlf & vbcrlf
strMsg = strMsg + &quot;Submitter Name:&quot; & &quot; &quot; & txtSName & vbcrlf & vbcrlf
strMsg = strMsg + &quot;Submitter Location:&quot; & &quot; &quot; & txtSLocation & vbcrlf & vbcrlf
strMsg = strMsg + &quot;Submitter Phone:&quot; & &quot; &quot; & txtSPhone & vbcrlf & vbcrlf
' strMsg = strMsg + &quot;Contact Requested:&quot; & &quot; &quot; & txtContact & vbcrlf & vbcrlf

end if

strMsg = strMsg & vbcrlf & vbcrlf
strMsg = strMsg & &quot;Sincerely,&quot; & vbcrlf
strMsg = strMsg & &quot;Rural Health Group Services&quot; & vbcrlf


set objMail = CreateObject(&quot;CDONTS.Newmail&quot;)
objMail.From = &quot;address&quot;
objMail.To = txtEMail
objMail.Subject = &quot;RHGS Lead from the Web&quot;
objMail.Body = strMsg
objMail.Send
set objMail = nothing
set strMsg = nothing

end if

' *************************
' Finally email info
' *************************

' Generate message

strMsg1 = strMsg1 + &quot;PLEASE DO NOT REPLY TO THIS EMAIL! THIS IS NOT AN ACTUAL EMAIL USER!&quot; & vbcrlf & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;The following information was entered from the TRH Internal Website:&quot; & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;First Name:&quot; & &quot; &quot; & txtFName & vbcrlf
strMsg1 = strMsg1 + &quot;Last Name:&quot; & &quot; &quot; & txtLName & vbcrlf
strMsg1 = strMsg1 + &quot;Company:&quot; & &quot; &quot; & txtCName & vbcrlf
strMsg1 = strMsg1 + &quot;Email Address:&quot; & &quot; &quot; & txtEmail & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;Phone:&quot; & &quot; &quot; & txtPhone & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;Fax:&quot; & &quot; &quot; & txtFax & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;Address:&quot; & &quot; &quot; & txtAddress & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;City:&quot; & &quot; &quot; & txtCity & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;Zip Code:&quot; & &quot; &quot; & txtZipCode & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;Comments:&quot; & &quot; &quot; & txtComments & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;Submitter Name:&quot; & &quot; &quot; & txtSName & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;Submitter Location:&quot; & &quot; &quot; & txtSLocation & vbcrlf & vbcrlf
strMsg1 = strMsg1 + &quot;Submitter Phone:&quot; & &quot; &quot; & txtSPhone & vbcrlf & vbcrlf
' strMsg1 = strMsg1 + &quot;Contact Requested:&quot; & &quot; &quot; & txtContact & vbcrlf & vbcrlf

' Now mail it

set objMail1 = CreateObject(&quot;CDONTS.Newmail&quot;)
objMail1.From = &quot;address&quot;
objMail1.To = &quot;address&quot;
objMail1.Subject = &quot;RHGS Lead from the Web&quot;
objMail1.Body = strMsg1
objMail1.Send
set objMail1 = nothing
set strMsg1 = nothing

' ************************************
' Now write out an acknowledgment page
' ************************************

%>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot; &quot;<html>
<head>
<title>Success</title>

</head>

<body BGCOLOR=&quot;WHITE&quot;>
<div align=&quot;left&quot;>

<table>
<tr>
<td WIDTH=&quot;500&quot; VALIGN=&quot;top&quot;><table WIDTH=&quot;616&quot; BORDER=&quot;0&quot; style=&quot;WIDTH: 616px; HEIGHT: 102px&quot;>
<tr>
<td HEIGHT=&quot;65&quot;><p align=&quot;left&quot;><font size=&quot;2&quot; color=&quot;Black&quot; face=&quot;tahoma,arial,helvetica&quot;><font face=&quot;Arial&quot;>Your group lead has been submitted.<br>
If you requested contact, someone will contact you shortly. <BR> An email confirmation has also been sent to the address that you provided.<br>
<br>
Sincerely,</font> <br>
<font face=&quot;Arial&quot; size=&quot;2&quot; color=&quot;#252525&quot;><em>Rural Health Group Services</em></font></font></td>

<tr align=&quot;left&quot; valighn=&quot;center&quot;><td><img alt=&quot;Tennessee Rural Health&quot; SRC=&quot; WIDTH=&quot;150&quot; HEIGHT=&quot;75&quot;><BR>
</tr>
</table>
</td>
<td WIDTH=&quot;5&quot; BGCOLOR=&quot;White&quot;></td>
</tr>
</table>
<form>
<input type=&quot;button&quot; value=&quot;Close Window&quot; onClick=&quot;window.close()&quot;>
</form>
</div>
</body>
</html>
 
Ok, 1) for your two if statements add a > 0 after them to make sure the position is inside the string (0 means not found)
2) Replace your +'s with &amp;'s
3) test it before reposting

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
 
tarwn is right about the &quot;if intIndex then&quot; part...

try this instead:
if intIndex > 0 then

also, your include file should be on the outside of the asp tags:
<!--#include file=&quot;cdovbs.inc&quot;-->
<%

instead of:
<%
<!--#include file=&quot;cdovbs.inc&quot;-->

Hope that helps...
mwa


 
Made the changes and tested. Still same error. Aldo below code is used to post to prior code. Thanks for the help.

<html>
<head>
<title>Submit RHGS Group Lead</title>
</head>

<body background=&quot; link=&quot;#CC0000&quot; vlink=&quot;#000000&quot; alink=&quot;#000000&quot;>


<form METHOD=&quot;POST&quot; action=&quot;emailleadinfo.asp&quot; name=&quot;form1&quot; >

<div align=&quot;left&quot;>
<table border=&quot;0&quot; width=&quot;487&quot; height=&quot;393&quot; cellspacing=&quot;1&quot;>
<tr>
<td width=&quot;477&quot; height=&quot;27&quot; colspan=&quot;2&quot;>
<p align=&quot;center&quot;>Enter Lead Information Below:</td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;34&quot; align=&quot;left&quot;>First Name</td>
<td width=&quot;322&quot; height=&quot;31&quot;>
<input type=&quot;text&quot; name=&quot;fname&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;33&quot; align=&quot;left&quot;>Last Name</td>
<td width=&quot;322&quot; height=&quot;30&quot;>
<input type=&quot;text&quot; name=&quot;lname&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;37&quot; align=&quot;left&quot;>Company</td>
<td width=&quot;322&quot; height=&quot;33&quot;>
<input type=&quot;text&quot; name=&quot;cname&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;32&quot; align=&quot;left&quot;>Number of Employees</td>
<td width=&quot;322&quot; height=&quot;38&quot;>
<input type=&quot;text&quot; name=&quot;employees&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;25&quot; align=&quot;left&quot;>Phone</td>
<td width=&quot;322&quot; height=&quot;26&quot;>
<input type=&quot;text&quot; name=&quot;phone&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;18&quot; align=&quot;left&quot;>Fax</td>
<td width=&quot;322&quot; height=&quot;24&quot;>
<input type=&quot;text&quot; name=&quot;fax&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;5&quot; align=&quot;left&quot;>Address</td>
<td width=&quot;322&quot; height=&quot;24&quot;>
<input type=&quot;text&quot; name=&quot;address&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;5&quot; align=&quot;left&quot;>City</td>
<td width=&quot;322&quot; height=&quot;24&quot;>
<input type=&quot;text&quot; name=&quot;city&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;5&quot; align=&quot;left&quot;>Zip Code</td>
<td width=&quot;322&quot; height=&quot;24&quot;>
<input type=&quot;text&quot; name=&quot;zipcode&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;15&quot; align=&quot;left&quot;>Comments</td>
<td width=&quot;322&quot; height=&quot;15&quot;>
<textarea rows=&quot;2&quot; name=&quot;comments&quot; cols=&quot;37&quot;></textarea></td>
</tr>
<tr>
<td width=&quot;477&quot; height=&quot;5&quot; colspan=&quot;2&quot;></td>
</tr>
<tr>
<td width=&quot;487&quot; height=&quot;28&quot; colspan=&quot;2&quot;>
<p align=&quot;center&quot;>Enter Submitter Information Below:</td>
</tr>
<tr>
<td width=&quot;156&quot; height=&quot;21&quot;>Name</td>
<td width=&quot;321&quot; height=&quot;21&quot;>
<input type=&quot;text&quot; name=&quot;sname&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;155&quot; height=&quot;30&quot; align=&quot;left&quot;>Email Address</td>
<td width=&quot;322&quot; height=&quot;33&quot;>
<input type=&quot;text&quot; name=&quot;email&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;156&quot; height=&quot;21&quot;>Location</td>
<td width=&quot;321&quot; height=&quot;21&quot;>
<input type=&quot;text&quot; name=&quot;slocation&quot; size=&quot;20&quot;></td>
</tr>
<tr>
<td width=&quot;156&quot; height=&quot;21&quot;>Phone</td>
<td width=&quot;321&quot; height=&quot;21&quot;>
<input type=&quot;text&quot; name=&quot;sphone&quot; size=&quot;20&quot;></td>
</tr>

<tr>
<td width=&quot;477&quot; height=&quot;21&quot; colspan=&quot;2&quot;>
<p align=&quot;center&quot;><input type=&quot;submit&quot; value=&quot;Submit&quot; name=&quot;submit&quot;><input type=&quot;reset&quot; value=&quot;Clear&quot; name=&quot;Clear&quot;></td>
</tr>
</table>
</div>

</form>

</body>

</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top