First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Jeffrey F. Hill | Website: http://www.flash-db.com

Option 3 - Setting up the ASP script to send mail with ASP

The following script shows you how to send mail with ASP - it works similar to the two methods shown above. This script is from a Popular Windows 2000 Hosting service called innerhost.  The main difference between a PHP based mailing script and an ASP based mailing script is the use of a mailing object. Many Win NT/2K Hosts have the Smtpsvg.dll registered on their servers. If they do not, please check with the Host to see what sort of mail object they do use. The code below is pretty self-explanatory. On line 12, be sure to change “mail.innerhost.com” to the SMTP mail server that your host provides. Also make sure to change lines 7-10 to your Name, Email, Subject etc.  This e-mail will work in the same manner as the previous two examples.

1)   <&quest
2)  FirstName = Request.form("FirstName")
3)  Email = Request.form("Email")
4)  Company = Request.form("Company")
5)  ToComments = Request.form("ToComments")
6)  HearAbout = Request.form("HearAbout")

7)  strName = "Your Name"
8)  strEmail = "YourEmail@YourSite.com"

9)  strSubject = "Tutorial Request Example Email"
10) strBody = ToComments & HearAbout & Company

11)  Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
12)  Mailer.RemoteHost = "mail.innerhost.com"
13)  Mailer.FromName = FirstName
14)  Mailer.FromAddress = Email
15)  Mailer.AddRecipient strName, strEmail
16)  Mailer.Subject = (strSubject)
17)  Mailer.BodyText = strBody

18)  if Mailer.SendMail then
19)  Response.Write "_root.Mail.EmailStatus=Complete - Your mail has been sent"
	else
20)  Response.Write "_root.Mail.EmailStatus=Failure - Your mail was not sent - errors"
21)  Response.Write Mailer.Response
22)  end if
23)  &quest>

Line 1 -  Starts the ASP script

Lines 2  to 6 - This captures the data sent with the header information from the post command and puts it into a format that the asp script can use. 

Lines 7 to 8 - Sets the Name and E-mail address to which you are sending this information to.  Make sure to change this to your own name and e-mail if you are going to be receiving this e-mail (or to the person that is).  

Line 9 - This sets the subject line of the message that you are sending.

Line 10 - Formats the contents of the inputted information into the Body of the Email.

Line 11 - This sets the Mailing object, that enables the script to send the E-mail.  This may be different, SMTPsvg.Mailer is the most common Mailing Object but can be different depending on your server. 

Line 12 - Make sure to change this according to your Host.

Lines 13 to 17 - Sets up the e-mail and assigns each different E-mail field it's previously defined vale. 

Lines 18 to 22 - Just checks to see if the mail was sent - If it was it prints out a Complete/success message back to the Flash movie.  If it was not successful then an error message is sent back to the flash movie.  

And that's about it with the ASP section - Remember that because of the wide variety of server setups and the ways that individual hosting services set up their server, this will not work all the time.  I tried to give the most general widely used examples - but you may have to contact your host for further information. 

» Level Advanced

Added: 2001-08-27
Rating: 9 Votes: 328
(10 being the highest)
» Author
No details available.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.