PDA

View Full Version : ASP form processing with email on an html site


JasonC
05-06-2009, 10:14 PM
Hi!

I do not know much about ASP, but I was tasked with creating a form for an HTML site, and processing said form and emailing the entered data with ASP.

I'm unable to install IIS and I'm running my ASP on our development server which is running an Apache server.

Here's my code:


<%@LANGUAGE="JAVASCRIPT"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>After Action Report Results</title>
</head>

<body>
<%
dim comname, date, poc, time, loc, comments
comname=Request.Form("comname")
date=Request.Form("date")
poc=Request.Form("poc")
time=Request.Form("time")
loc=Request.Form("loc")
comments=Request.Form("comments")
%>

<%
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")

//This section provides the configuration information for the remote SMTP server.

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 //Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpserver.mail.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False //Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60

// If your server requires outgoing authentication uncomment the lines below and use a valid email address and password.
//ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
//ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com"
//ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"

ObjSendMail.Configuration.Fields.Update

//End remote SMTP server configuration section==

ObjSendMail.To = "soandso@email.com"
ObjSendMail.Subject = "Report"
ObjSendMail.From = "ACC"


ObjSendMail.HTMLBody = "Report<br /><br />
Community Name: <b><% Response.write(comname) %></b><br />
Date: <b><% Response.write(date) %></b><br />
Event Planner or Point of Contact: <b><% Response.write(poc) %></b><br />
<br />
Time: <b><% Response.write(time) %></b><br />
Location: <b><% Response.write(loc) %></b><br />
Additional Comments: <b><% Response.write(comments) %></b><br />"

//for text-only body
//ObjSendMail.TextBody = "this is the body"

ObjSendMail.Send

Set ObjSendMail = Nothing
%>

Thank you for submitting your Report!
<br />
<br />
Please use your browser's "back" button to return to the page.


</body>
</html>



The above is from my formProcess.asp file which I currently have set in the "action" attribute of the form tag on the report.html page (which is the page with the form on it).

Can anybody tell me what I'm doing wrong?

Old Pedant
05-07-2009, 12:49 AM
Ummm...you can't run ASP on an Apache server.

Unless you are using Sun's version of ASP. And if you are using it, then more than likely it doesn't support CDO.Message.

*ARE* you using Sun's version of ASP???

[Not completely relevant, but Sun has declared the product obsolete and will completely cease support of it in next couple of years.]

Oh...and what Operating System are you using???

JasonC
05-07-2009, 03:09 PM
I don't think I'm using Sun's version of ASP. My code is based on examples from w3schools.com, and I'm not exactly sure what version of Apache is running on the development server.

My OS is Windows XP, and the development server is a unix box.

brazenskies
05-07-2009, 03:22 PM
how on earth???

JasonC
05-07-2009, 03:39 PM
how on earth???

This is extraordinarily helpful. Thank you.

JasonC
05-07-2009, 05:53 PM
Can anybody at least tell me if I have the syntax correct for what I'm trying to do?

I think I found an IIS server I can test on, but I don't have direct access to it. So I'd like to start with mostly correct code so that I can minimize the amount of times I have to test it.

brazenskies
05-07-2009, 08:06 PM
what errors are you getting?

JasonC
05-07-2009, 08:12 PM
Not getting any error message. Just getting this as output:

Date:
Event Planner or Point of Contact:

Additional Comments:
" //for text-only body //ObjSendMail.TextBody = "this is the body" ObjSendMail.Send Set ObjSendMail = Nothing %> Thank you for submitting your report!

Please use your browser's "back" button to return to the page.

Old Pedant
05-07-2009, 09:27 PM
So indeed that server is *NOT*capable of running ASP code.

If you see the <% or %> tags in your browser--even if you have to use VIEW-->>SOURCE to do so--then the ASP code is not being processed on the server.

Actually, I should have tumbled to this in your first post.

You are using JavaScript style comments:

//This section provides the configuration information for the remote SMTP server.

(the // is used in JavaScript--and Java and C and ...but never in VBScript--to introduce a comment)

But you are using VBScript syntax:

Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")

No other language uses DIM and SET like that.

So... Your code is wrong (change the // to just a single apostrophe, at a minimum) but so long as you are running on an Apache web server, the whole thing is moot, as you won't be able to use ASP there.

You perhaps should shift to JSP or PHP.