Solved

How to send email through button in action script.

Posted on 2009-04-13
5
1,360 Views
Last Modified: 2013-11-11
I am a beginner in flash. i am trying to send my 5 text field data to one email address. i make a two button. one for clear the field and second for send an email. first button is working fine.please send me the code for sending email function. i am using following code for clear the all text field.

on (release)
{
    _parent.f_name.text = "";
    _parent.l_name.text = "";
    _parent.mail.text = "";
    _parent.address.text = "";
    _parent.zip.text = "";
    _parent.phone.text = "";
    _parent.mess.text = "";
}
0
Comment
Question by:navedj786
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:john_hollings
ID: 24129380
You need to load the form data fields into a LoadVar and then send them to a email script page such as php, asp, cfm etc.  This script page willl actually send the email.  I have provided the script for the button and the script in php.

Hope this helps.
//--------------- FLASH AS2 CODE ------------------//

//When the user clicks submit do the following

send_btn.onRelease = function ()

{

     //Create a new instance of the LoadVars class

     var _loc3 = new LoadVars();

     //If the loading of the form variables is successful to the following

     _loc3.onLoad = function (success)

     {

         if (success)

         {

            //success code here

         }

         //If not then do this

         else

         {

	//handle error code here

         }

      };

      

        var _loc2 = new LoadVars();

        //Load the value of the form fields

        _loc2.fullname = name_txt.text;

        _loc2.email = email_txt.text;

        

        //send the values to a email script

        _loc2.sendAndLoad("location of email script", _loc3, "POST");

};
 

// ------------- PHP EMAIL ACTION PAGE ---------------

<?php
 

$visitor = $_POST['name_txt']; 

$visitormail = $_POST['email_txt']; 
 

$todayis = date("l, F j, Y, g:i a") ;
 

$subject = "Email Subscription Request"; 
 

$message = "your message. \n

Name: $visitor\n

Email: $visitormail \n

Sent: $todayis \n

";
 

$from = "From: $visitormail\r\n";
 

mail("email address", $subject, $message, $from);
 

?>

Open in new window

0
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 24147580
if you don't want the backend option you can also use a mailto which will open the users default mail client i.e. outlook

on (release) {
mailto:addy@whereever.com?subject=whatever?body=whatever
}
0
 

Author Comment

by:navedj786
ID: 24234587
Dear,

Thank you for your comment.
i have no idea about php backend.
i am trying to use following code
on (release) {
mailto:addy@whereever.com?subject=whatever?body=whatever
}

Can i use variable value in place of subject,body and other field, if yes then please show me.
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 24248239
yes you can. exactly as above where whatever is your variable.
0
 

Author Closing Comment

by:navedj786
ID: 31569442
Thank you dear, this solution is really helpfull for me becasue i dont have any idea about backend support, thanks again.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to put actionscript code for a button? 6 118
How do I convert a CS4 FLA file to CS6? 1 867
To view Flash technology content error 4 6,498
Microsoft WSUS 4 90
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now