| |
LiveMotion Forms - Part III
Setting up our ASP Script.
Our ASP script is an incredible 14 Lines of code. (we start from
00) Copy this code to a new text file and name it lmcMail.asp
Again, remember to remove the line numbers before running your
code.
--- CODE ---
00
<%
01 Response.Expires = 0
02 Response.Expiresabsolute = Now-1
03 Dim objMail
04 Set objMail = Server.CreateObject("CDONTS.NewMail")
05 objMail.From = request.form("txtEmail")
06 objMail.Subject = "Put your subject here."
07 objMail.To = "you@yourdomain.com"
08 objMail.Body = "Message from LM2 / ASP Form" &
vbCrLf & vbCrLf & "Name: " & request.form("txtName")
& vbCrLf & "Email: " & request.form("txtEmail")
& vbCrLf & "URL: " & request.form("txtURL")
& vbCrLf & "Comments: " & vbCrLf & request.form("txtComments")
& vbCrLf & vbCrLf & "Message Complete"
09 objMail.Send
10 strComplete = "&txtStatus=" & Server.URLEncode("Complete
- Your message has been sent!")
11 Response.Write strComplete
12 set objMail = nothing
13 %>
--- CODE ---
Line 00: This opens our ASP script, like we would an html
tag using the less then key. <
Line 01: Here we setup an expiration. We do not want our
ASP code to be cached in the browser, if it is, some times the
code will have problems. I am not totally sure whey, I just know
that not letting the ASP file to be cached has fixed TONS of small
problems for me in using this script.
Line 02: Here we tell the document to expire now.
Line 03: Dim is a how you call a variable. Like with Javascript
and Actionscript, you would use var, with ASP, we use Dim, our
variable name is objMail.
Line 04: Here we give the Dim objMail a value. Because
we are using CDONTS, we set it to CDONTS.NewMail, if you are using
another mail component like JMail, you would set your servers
mail object here.
Line 05: Here we set the From field. when you get the email,
you will see that it is from the email address your visitor enters
into the txtEmail text field.
Line 06: Here we setup our subject line for our email.
Change this as needed.
Line 07: This is where your message will be sent, put your
email address here.
Line 08: Here is the body of our message, In Javascript
when you seperate a string, from a value, you use the + symbol,
in ASP you use the & symbol. The vbCrLf is a line break, or
like a <br> command. So if you want a paragraph break, you
need to have two.
Line 09: This is where we send the message.
Line 10: Because we are using the URL to pass information
back to our swf file, we have to URLEncode the text back to the
swf. So strComplete is setting a name to the string we are building.
When the message has been sent, it will load this comment, back
into the swf's status text field... That is the cool thing, we
are sending a message from the ASP script back to the SWF file,
letting the user know that the message was sent.
Line 11: Response.Write is like Javascripts document.write().
We are writing information back to the document, in this case,
back to the swf file.
Line 12: Here we kill the objMail process... Now you HAVE
TO DO THIS. Imagine your web hosting service has 100 + people
using the same machine, and imagine all of them are using the
CDONTS mail object, now imagine NONE OF THEM END THE PROCESS!
that would really trash your servers response time. So KILL DAT
PID AND FREE THE PROCESS!
Line 13: Closes the ASP script.
If your only doing the ASP script, skip to the end of this tutorial
part
1
2
3
4
5
6
|