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!

simple feedback form doesn't work

Status
Not open for further replies.

jayjay66

Technical User
Oct 31, 2005
114
Hi,

I really need help here because I have no clue why it's not working. It technically should work and I don't really get an error messages. This is a simple "feedback form" where the user puts his comments and clicks on "Submit" & the results are sent to my email address. The problem seems that I don't get the email that's sent. I don't get any errors either. Can somebody please help me with this simple problem. Here is the code:



<html>
<head>
<title>Feedback Form</title>
</head>
<body>

<%
'If the form has not been submitted execute the following code
If Request.Form="" Then %>
<form method="post" action="feedback.asp" name="form1">
<div align="center">Send us your Feedback<br>
<br>
</div>
<div align="center">
<table width="75%" border="0">
<tr>
<td>name</td>
<td>
<input type="text" name="txtName">
</td>
</tr>
<tr>
<td>email</td>
<td>
<input type="text" name="txtEmail">
</td>
</tr>
<tr>
<td>comment</td>
<td>
<textarea name="txtFeedback" cols="40" rows="7"></textarea>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</td>
</tr>
</table>
</div>
</form>
<br>
<%
'If the form has been submitted execute the following code
Else

'receive the form values
Dim sName, sEmail, sFeedback
sName=Request.Form("txtName")
sEmail=Request.Form("txtEmail")
sFeedback=Request.Form("txtFeedback")

' create the HTML formatted email text
Dim sEmailText
sEmailText = sEmailText & "<html>"
sEmailText = sEmailText & "<head>"
sEmailText = sEmailText & "<title>HTML Email</title>"
sEmailText = sEmailText & "</head>"
sEmailText = sEmailText & "<body>"
sEmailText = sEmailText & "Feedback message from: " & sName & "<br>"
sEmailText = sEmailText & "Message:" & sFeedback & "<br>"
sEmailText = sEmailText & "Date & Time:" & Now() & "<br>"
sEmailText = sEmailText & "IP :" & Request.ServerVariables("REMOTE_ADDR")
sEmailText = sEmailText & "</body>"
sEmailText = sEmailText & "</html>"

'create the mail object
Set NewMailObj=CreateObject("CDO.Message")
NewMailObj.From=sEmail 'This is the email of the feedback sender
NewMailObj.To = "my-email-address@mydomain.com" 'change to my address
NewMailObj.Subject = "Feedback"
NewMailObj.TextBody = sEmailText
NewMailObj.Send
Set NewMailObj=Nothing

Response.write "<div align='center'>Thank you for sending your feedback.<br>"
Response.write "We will get back to you if necessary.</div>"
End If
%>
</body>
</html>

Many thanks. I'm sure I'm overlooking something.

Thanks,
JJ
 
Your code is fine (although could be formatted)

Sense there is nothing wrong with it it must be a server setting or dll issue. Have you validated the cdosys.dll is in the system32 folder and registered? Also is the local smtp service running

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
You may need to check if your SMTP server requires authentication

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Hi All,

Yup the SMTP service is running. The cdosys.dll is in the system32 folder. How can I tell if cdosys.dll is registered??

Please let me know becuase I really don't know what to do.

Thanks,
JJ
 
start-->run

enter regsvr32 cdosys.dll

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
btw...that registers the dll. Try the script after doing that.

Are you running this on your local machine or a server? (with in a network)

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
Option 1) Somewhere buried in IIS is a default forwarding SMTP server address, but it's been so long I can't even find it anymore.

Option 2) Setup Outlook express. Silly, I know, but apparently if you set up at least one account in Outlook express on the machine it sets the defauls in a dozen other places.

Option 3) Extend your code to include the CDO configuration object so you can set the mailserver on the fly. Also adds cpabilities for HTML-based mail. etc:
Code:
Set cdoConf = Server.CreateObject("CDO.Configuration")
set cdoFlds = cdoConf.Fields
With cdoFlds
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
	.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = "mail.yourdomain.com"
	.Update
End With
Set NewMailObj.Configuration = cdoConf

The pitfall of #3 is that every piece of code with email capabilities is configuired in that piece of code, so changing it means changing them all. The positive is that at least you kno where you set it and you don't have to go find it again and it also helps when you don't have access to IIS (ie, web hosting with someone else).
-T

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top