Link to home
Start Free TrialLog in
Avatar of apriilgem
apriilgem

asked on

Send email from Flash form

I am trying to create a form in Flash that gets a users email address and sends it to an email address I specify. I've looked at countless tutorials and I just don't get it. I need something simple and I can't seem to find anything like this. I have a text box for the user to enter the email address and a button. What scripts do I need to place on the button and what should my asp page look like? I'll take whatever I can get at this point this is clear and easy to understand and edit. Thanks!
Avatar of biztiger
biztiger
Flag of India image

Avatar of apriilgem
apriilgem

ASKER

Thanks but I need to know how to make this work with Flash 8.  How do I get the input from the text field in Flash and send it to the asp page, which will then email it to another address? I don't understand how to edit this example to suit my purpose. Don't I need to put in the mail server information? I do know a little bit about asp, but not enough to solve this problem.
First of all. Get your asp file working correctly. i.e create a html form and use this to test the asp file sends the email to wherever you are wanting to send it.

Once you know this is working you're half way there.

If you let me know the name of the asp script the form is sending to and the name of the email field I'll knock up a quick flash file for you so you can see what is happening.
Go through the article. Start with "Creating the Flash Form" and end reading on page 3 (after you learn how to recieve dat from flash to asp)
http://www.sorbose.com/pdf/Build%20a%20Database%20with%20Flash%20form%20&%20ASP.pdf

You'll know everything how to send data from flash to asp effectively. Now after receiving the data in asp, go through the following tutorial to send the email from asp.

Check this out to know how to send email with asp
http://www.sitepoint.com/article/sending-email-asp/
Ok, I've searched around and this is the code I ended up with:

<%
set myMail=CreateObject("CDO.Message")

myMail.Subject="Sending email with CDO"
myMail.From="remi@designdal.com"
myMail.To="remi@designdal.com"
myMail.TextBody="This is a message."

myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail4.brinkster.com"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Update
myMail.Send

%>


I am trying to make the asp work first as suggested and then go from there. This does not work however and gives me this error message:

(error '8004020f'
/tp/mailtest.asp, line 28 )

Can someone please let me know what I might be doing wrong.


I've been able to get the code to work to send email, but now I need to figure out how to get it to get info from a flash form. This is the code that ended up working for me:

<%
set myMail=CreateObject("CDO.Message")

myMail.Subject="Sending email with CDO"
myMail.From="remi@designdal.com"
myMail.To="remi@designdal.com"
myMail.TextBody="This is a message."

myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "sendmail4.brinkster.com"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") = "remi@designdal.com"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
myMail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

myMail.Configuration.Fields.Update
myMail.Send

%>

I'm halfway there! I just need help with the last part.
The attached fla is an example of how the flash form posts data to the asp script.
In this example the variables username and passwd are passed (currently to login.asp)

This solution requires the asp script to send something back to the browser, such as a new page or Location URL.

FYI you can also send data from flash without refreshing the contents of the browser window using sendAndLoad. Flash Help has some great examples for you to try out if this options is preferred.
sendData.fla.txt
Thanks, but that file comes up looking crazy and I can't read it.
try downloading the file and removing the .txt from the name so you end up with a .fla extension
Ok, I've got it so that when i enter info into the Flash form, it goes to the email address, but the info that shows up has the textbox attributes included from the Flash file. How would I get rid of this and just have it so that only what the user typed into the box shows up?

Also, now that I've figured all this out, I find out the server doesnt support asp files unless I create and .htaccess file. Anyone know how I would go about doing that? Its slow going, but I'm getting it in pieces...lol
The separation of the name/value pairs is something that the .asp file does. Unfortunately I don't know anything about asp!

If it were done using PHP the code would look something like:

$email = $_POST['email'];
$message = $_POST['message'];
Ok, then can you tell me how to do the same thing I am trying to do using php? I don't have time for a whole tutuorial. I would just love the code. Or something close to what I need and I can alter it to suit my purpose. Thanks!
ASKER CERTIFIED SOLUTION
Avatar of crooksy88
crooksy88
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hello:

I was looking at this solution but had a doubt about what should go in here.

$headers .= "Message-ID: <".date("YmdHis")."$xServerName@".$_SERVER['SERVER_NAME'].">\n";

Should the real mail server name go in place of 'SERVER_NAME' or not? I wasn't sure where the server name, for example. mail.domain.com or smtp.domain.com should go.

Thanks,

joseph
That line shouldn't need to be altered. .$_SERVER['SERVER_NAME']. is taken from the environment vars.