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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't get my asp page to email

Status
Not open for further replies.

bikebanditcom

Programmer
Jun 11, 2003
117
US
can any one help? im trying to get my page to email form results to me, however i can't get it to work the following two pages are used to proceess the form..

the html form

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JavaScript>
<!--
function DoctorElements()
{
var i,j;
for (i=0; i < document.forms[0].elements.length-1; i++)
switch (String(document.forms[0].elements.name).substring(0,3))
{
case &quot;chk&quot;:
if (document.forms[0].elements.checked)
document.forms[0].elements.value = &quot;Yes&quot;;
else {
document.forms[0].elements.checked = true;
document.forms[0].elements.value = &quot;No&quot;;
}
break;
}
}
// -->
</SCRIPT>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION=&quot;mailForm.asp&quot; ONSUBMIT=&quot;DoctorElements();&quot;>
<INPUT TYPE=HIDDEN NAME=&quot;urlSendTo&quot; VALUE=&quot;thankyou.htm&quot;>
<INPUT TYPE=HIDDEN NAME=&quot;urlFromPath&quot; VALUE=&quot;default.htm&quot;>

Name: <INPUT TYPE=TEXT NAME=&quot;txtUser.Name&quot;><BR>
Age:
<SELECT NAME=selUser.Age SIZE=1>
<OPTION VALUE=&quot;Under 18&quot;>Under 18</OPTION>
<OPTION VALUE=&quot;18 - 24&quot;>18 - 24</OPTION>
<OPTION VALUE=&quot;25 - 40&quot;>25 - 40</OPTION>
<OPTION VALUE=&quot;Over 40&quot;>Over 40</OPTION>
</SELECT><BR>

Sex:
<BR>
<INPUT TYPE=RADIO NAME=radSex VALUE=&quot;Male&quot; CHECKED>Male<BR>
<INPUT TYPE=RADIO NAME=radSex VALUE=&quot;Female&quot;>Female
<P>
I like cheese: <INPUT TYPE=CHECKBOX NAME=chkI.Like.Cheese>

<P><INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>

the asp script

<%@ Language=VBScript %>
<% Option Explicit %>
<%
'The header/footer for the email.
Const strHeader = &quot;Here are the results of the form:&quot;
Const strFooter = &quot;Form mailer created by 4GuysFromRolla.com, 1999&quot;

'Who does this go to? MAKE SURE TO CHANGE THIS TO YOUR EMAIL ADDRESS!
Const strTo = &quot;danhaydenjr@hotmail.com&quot;

'This information is optional
Dim strFrom, strSubject, strRedirectURL, strFromPath

strFrom = Request.Form(&quot;txtSendToEmailAddress&quot;)
if Len(strFrom) = 0 then strFrom = strTo

strSubject = Request.Form(&quot;txtEmailSubject&quot;)
if Len(strSubject) = 0 then strSubject = &quot;FORM EMAILER: 4GuysFromRolla.com&quot;

strRedirectURL = Request.Form(&quot;urlSendTo&quot;)
if Len(strRedirectURL) = 0 then strRedirectURL = &quot;/&quot;

strFromPath = Request.Form(&quot;urlFromPath&quot;)
if Len(strFromPath) = 0 then strFromPath = &quot;UNKNOWN&quot;

Dim strBody
strBody = strHeader & ( vbCrLf & vbCrLf )
strBody = strBody & ( &quot;FORM: &quot; & strFromPath & vbCrLf ) & _
( &quot;FORM submitted at &quot; & Now() & vbCrLf & vbCrLf )

dim ix, formElementName, formElementValue, prefix, fldName
For ix = 1 to Request.Form.Count
formElementName = Request.Form.Key(ix)
formElementValue = Request.Form.Item(ix)

' what type of field was that on the form?
prefix = Left(formElementName,3)

' and throw away prefix to get actual field name
fldName = Mid(formElementName,4)

' but change periods to spaces for readability
fldName = Replace(fldName, &quot;.&quot;,&quot; &quot;)

Select Case prefix
' if the prefix indicates this is a form field of interest...
Case &quot;txt&quot;,&quot;sel&quot;,&quot;rad&quot;,&quot;cbo&quot;,&quot;lst&quot;,&quot;chk&quot;:
' if user didn't answer this question, say so...
if Len(formElementValue) = 0 then formElementValue = &quot;UNANSWERED&quot;

' then tack on the name of the field and the answer
strBody = strBody & (fldName & &quot;: &quot; & formElementValue & vbCrLf)
End Select
Next

strBody = strBody & ( vbCrLf & strFooter )

'Time to send the email
Dim objCDO
Set objCDO = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objCDO.To = strTo
objCDO.From = strFrom

objCDO.Subject = strSubject
objCDO.Body = strBody

objCDO.Send

Set objCDO = Nothing

'Send them to the page specified
Response.Redirect strRedirectURL
%>

i get a page cannot be displayed after putting it up on a server that is an NT box...any ideas why or does anyone have any better idea of how to do this? Thanks alot

dan
 
Is there any error message in relation to a line in the code. Is your ASP page definitely called mailForm.asp?

Mighty
 
my form is definatly named mailform.asp, and no there are no errors regarding the asp, just a page cannot be displayed.

dan
 
According to the code in your HTML form, you are processing this form using /scripts/formmail.asp. However, in your post above you mention mailForm.asp - different files. Make sure that you are calling the correct program and that it does exist in the scripts folder and that your path to the scripts folder is correct.

Mighty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top