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!

email form contents from html using asp

Status
Not open for further replies.

woodje

Technical User
May 24, 2004
16
US
Hello,

I have a form in html that I am trying to email the contents to a location using an asp page. I have included the code for the form and the asp page below. When I exectue this I am getting an http 500 internal error. Please take a look and let me know your thoughts.

Jeff

Form ***
<form id="client_email" action="contact.asp" method="GET">

<tr>
<td class="user main" bgcolor="#eeeeee" background="img/spacer.gif">
<div><div align="right"><font size="2">Full name:</font><!--"''"--></div></div>
</td>
<td class="user main" bgcolor="#FFFFFF" background="img/spacer.gif" TlxField="area1" align="left" valign="middle">
<div>
<!--fe --><input type="text" name="client_name" value="" maxlength="200" size="30">
<!--/fe --></div>
</td>
</tr>
<tr>
<td class="user main" bgcolor="#eeeeee" background="img/spacer.gif">
<div><DIV align=right><FONT size=2>Email address:</FONT><!--"''"--></DIV></div>
</td>
<td class="user main" bgcolor="#FFFFFF" background="img/spacer.gif">
<div>
<!--fe --><input type="text" name="client_senderemail" value="" maxlength="200" size="30">
<!--/fe --></div>
</td>
</tr>
<tr>
<td class="user main" bgcolor="#eeeeee" background="img/spacer.gif">
<div><DIV align=right><FONT size=2>Comment or question:</FONT><!--"''"--></DIV></div>
</td>
<td class="user main" bgcolor="#FFFFFF" background="img/spacer.gif">
<div>
<!--fe --><textarea name="client_message" cols="30" rows="5"></textarea>
<!--/fe --></div>
</td>
</tr>
<tr>
<td class="user main" bgcolor="#eeeeee" background="img/spacer.gif">
<div><DIV align=right><FONT size=2>What is the best way to contact you?</FONT><!--"''"--></DIV></div>
</td>
<td class="user main" bgcolor="#FFFFFF" background="img/spacer.gif">
<div>
<!--fe --><input type="radio" name="client_contactway" value="email"><font size="2">By email</font>
<!--/fe --></div>
<div>
<!--fe --><input type="radio" name="client_contactway" value="phone"><font size="2">By phone</font>
<!--/fe --></div>
</td>
</tr>
<tr>
<td class="user main" bgcolor="#eeeeee" background="img/spacer.gif">
<div><DIV align=right><FONT size=2>If by phone, what is the best time of day to get in touch with you?</FONT><!--"''"--></DIV></div>
</td>
<td class="user main" bgcolor="#FFFFFF" background="img/spacer.gif">
<div>
<!--fe --><textarea name="client_contacttime" cols="30" rows="5"></textarea>
<!--/fe --></div>
</td>
</tr>
<tr>
<td class="user main" bgcolor="#eeeeee" background="img/spacer.gif" align="center" valign="middle">&nbsp;</td>
<td class="user main" bgcolor="#FFFFFF" background="img/spacer.gif" align="center" valign="middle">
<div>
<!--fe --><input type="image" src="img/submit_white.gif" name="submit" value="Submit">
<!--/fe --></div>
</td>
</tr>
</form>

Asp contact code
<%
Dim ObjSendMail
Dim iConf
Dim Flds

set reg = New RegExp
reg.Pattern = "^[A-Za-z0-9\._\-]+@([A-Za-z0-9\._\-]+\.)+[A-Za-z0-9\._\-]+$"
set m = reg.Execute(Request.QueryString("client_email"))

name = Request.QueryString("client_name")
senderemail = Request.QueryString("client_senderemail")
message = Request.QueryString("client_message")
contactway = Request.QueryString("client_contactway")
contacttime = Request.QueryString("client_contacttime")

Set ObjSendMail = Server.CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields

Flds(" = 1

'**** Path below may need to be changed if it is not correct
Flds(" = "c:\inetpub\mailroot\pickup"
Flds.Update

Set ObjSendMail.Configuration = iConf
ObjSendMail.To = "webmaster@jwcsconsultingservice.com"
ObjSendMail.Subject = "A message from your Contacts Page from " & name &
ObjSendMail.From = "contactform@junkcarsfl.com"

' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "<html><head><title>Contact Letter</title></head><body><br>" & street & & city & & state & & zip & & name & & senderemail & & message & & contactway & & contacttime & "</body></html>"
ObjSendMail.TextBody = "this is the body"

ObjSendMail.Send
Response.Write("Your email was sent")

Set ObjSendMail = Nothing
%>
 
in IE:

Tools -> Internet Options -> Advanced

Scroll down to where it says "Show Friends HTTP Error Messages" - uncheck that box.

Reload the page and report back the detailed error message + line number... (you may need to re-start IE to get the detailed error msg)



TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Thanks for the response I made the change you requested. I am gettting the page cann't be displayed. I restarted IE as well.
 
does "contact.asp" exist in the same directory as the file where your form is located?

If yes, then what happens when you try to go directly to it?





TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
also, for once we get this issue sorted out, your form should have a method of "post" and your contact page should do a request.form instead of request.querystring.

Querystrings are limited to ~255 characters and you need to do checks to ensure characters like "&" are not passed through one of the forms.

I.e. if the message is:

"This is my message & this is more of my message"

The ampersand above will break the querystring.

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Yes it is in the same directory and I get the same error when I try and go to the contact page directly.
 
I will make that change once we have it working thanks for that advice.
 
Perhaps the guys over at the ASP forums may be able to help a bit more, as it stands it looks to be an ASP issue rather than HTML.

forum333
forum855



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
you can post it in the ASP form as per vacunita's advice...

I post there as well, but a "page cannot be displayed" error usually is caused by the page not existing where you are trying to access it.

If the page did exist and you have the "show friendly http error messages" box unchecked, you should get a detailed description of the error including the line number that is causing the page to break.

Try this:

at the very top of the "contact.asp" (first two lines) write:

Code:
<% response.write "Hello World" %>
<% response.end %>

then go directly to the page - what do you see?

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top