- Creating and Sending eGreetings
- Preparing to Work
- Working with the Card Template
- Applying the Scrollbar
- Customizing the Scrollbar
- The eGreeting Interface
- Defining the Structure of the Database
- Using the LoadVars Object to Send Data
- Error Checking
- Setting Up and Testing the Email Program
- Displaying the Card for the Recipient
- Putting It All Together
Setting Up and Testing the Email Program
When you have ensured that data can be successfully sent from Flash to ASP, have a record written to the database, and have the correct return string produced by your ASP script, you're 90% done. The one remaining hurdle is to make sure the mail program functions correctly.
Whatever program you normally use to send mailwhether it's a CGI script, ASPMail, or something elseis the one you should use for this application. As long as you can specify the sender address, recipient address, message body, and subject, you're set. (You'll also need to capture whatever information is returned from the script to tell if an error occurred so that you can pass that back to Flash and inform the user.) If your site is on a server that supports ASPMail, you can use the script found on the accompanying CD-ROM and just change the remote host specification.
Substitute whatever coding you need to tell the email program to use variables passed with a POST, as in this code:
Code the capture and return of any error information with code whose function matches this:
Mailer.FromName = request.form("fromName") Mailer.FromAddress = request.form("fromEmail") Mailer.AddRecipient request.form("toName"), request.form("toEmail")
Code Listing 9: This code assigns the variables passed from Flash to the Mailer object that will be used by ASPMail.
if not Mailer.SendMail then Response.write "mailError=1" else Response.write "mailError=0" end if
Code Listing 10: If mail is not successfully sent, the value of mailError, which is passed back to Flash, is set to 1.
As previously mentioned, I suggest you test the mail program by calling it from an HTML form (sending to your own address) before trying to use it with Flash. A sample HTML form is included on the accompanying CD-ROM, and the key content is listed here. If you fill out the information, click Send, see errorCode=0 pop up in the browser, and find a message in your inbox, you know the mail program works with the same fields your Flash movie will provide.
Figure 10.11. Testing the email program using a simple HTML form with the same data that the program will be receiving from Flash is a useful first step to ensure that the program works as intended.