Flash Gallery | Flash Templates | Flash Menu | Flash Design | Flash Audio & Video

flash page flip

Actionscript 3.0 video tutorials

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: mailTo method

  1. #1
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,609
    Rep Power
    9

    mailTo method

    flash templates

    Do you remember the old method mailto of Actionscript 2.0 used together with getURL that allowed to open the mail client of the user"

    Do you think that with Actionscript 3.0, it is not possible anymore"

    Wrong!

    Even with the third version of Actionscript it is possible to use this command. It simply needs to be associated to the new method navigateToURL .


    In this tutorial, I will show how to use 2 different methods, a simple one and a more complex one.


    Example 1

    I create a FLA and I save it as "main.fla".
    Into which, I create a button that I instantiate on stage and I assign to it the instance name "myButton".

    I open the action panel and I write:
    Code:
    function openMailClient(event:MouseEvent):void
    {
       var request:URLRequest=new URLRequest();
       request.url="mailto:info[noSpam]flepstudio.org";
       navigateToURL(request,"self");
    }
    myButton.addEventListener(MouseEvent.CLICK,openMailClient);
    And this the result:







    Let us analyse the code

    In the function openMailClient, I declare a new variable of type URLRequest and I assign to it as URL a string that contains the command mailto: followed of the eMail address to which the Mail Client (for example Outlook Express) will send the message.
    Next, I use the method navigateToURL and I pass to it, as parameters, the variable URLRequest (named "request") and "_self".
    I add a listener to the event MouseEvent.CLICK to "myButton" that will call the function openMailClient on click of the mouse on the button.

    Example 2
    With this example, other then passing the value for the eMail address to the user"s Mail Client, we will also pass the subject and body of the message.

    I create a FLA and I save it as "main2.fla".
    Into which, I create a button. I instantiate it on stage and I assign the instance name "myButton".
    I create 3 text fields: 2 dynamic ones named "to_txt" and "subject_txt" and the third one, an input text field named "body_txt".
    I open the panel action and I write:
    Code:
    to_txt.text='info@flepstudio.org';
    subject_txt.text='eMail from website';
    function openMailClient(event:MouseEvent):void
    {
       var request:URLRequest=new URLRequest();
       request.url="mailto:"+to_txt.text+""subject="+subject_txt.text+"&body="+body_txt.text;
       navigateToURL(request,"_self");
    }
    myButton.addEventListener(MouseEvent.CLICK,openMailClient);
    And this is the result:







    The code used is based on the first example.
    The difference is that we add parameters to the url of the variable "request" which is also of type URLRequest.

    Stay tuned !

  2. #2
    Junior Member Settled In paplone is on a distinguished road
    Join Date
    Dec 2007
    Posts
    4
    Rep Power
    0

    Re: mailTo method

    Cool simple demonstration of sending email. Will you be doing a tutorial where sending email doesn't involve triggering the recipient's client email?

    paplone

  3. #3
    Administrator Living At The FlepStudio! Flep is on a distinguished road
    Join Date
    Jul 2007
    Posts
    5,609
    Rep Power
    9

    Re: mailTo method

    Quote Originally Posted by paplone View Post
    Cool simple demonstration of sending email. Will you be doing a tutorial where sending email doesn't involve triggering the recipient's client email?

    paplone
    Hi

    At the moment you can download the email form:
    http://www.flepstudio.org/forum/down...?do=file&id=45

  4. #4
    Junior Member Settled In moo74 is on a distinguished road
    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0

    Re: mailTo method

    I have a problem when using this code. for some reason a webpage and an email client opens up is there an extra code I need to insert. Here is my code

    stop();

    email1_btn.addEventListener(MouseEvent.CLICK,email 1);
    function email1(event:MouseEvent):void
    {
    var request:URLRequest=new URLRequest();
    request.url="mailto:first.last@cbre.com";
    navigateToURL(request,"self");
    }

  5. #5
    Junior Member Settled In moo74 is on a distinguished road
    Join Date
    Mar 2008
    Posts
    3
    Rep Power
    0

    Re: mailTo method

    I figured out that the culprit is Windows Explorer because it doesn't happen in Firefox. Is there a script I can put in the html to say no pop-up? Or is there another way around this?

    Thanks!
    moo74

  6. #6
    Junior Member Settled In cangrejero is on a distinguished road
    Join Date
    Aug 2008
    Posts
    4
    Rep Power
    0

    Re: mailTo method

    Flep ... I'm trying to access but I'm not allowed. Could you assist? Any help appreciated. Thanks!!!

  7. #7
    Junior Member Settled In cangrejero is on a distinguished road
    Join Date
    Aug 2008
    Posts
    4
    Rep Power
    0

    mailTo method

    I'm flabbergasted! I can't make this work (either method) when I code it in Flash. My site is in CS3. Could that be the reason? Any help appreciated. Thanks!!

  8. #8
    CSS.FlepStudio.org Moving My Stuff To The FlepStudio Onsitus is on a distinguished road Onsitus's Avatar
    Join Date
    Jul 2007
    Posts
    1,405
    Rep Power
    5

    Re: mailTo method

    Quote Originally Posted by cangrejero View Post
    I'm flabbergasted! I can't make this work (either method) when I code it in Flash. My site is in CS3. Could that be the reason? Any help appreciated. Thanks!!
    You are using flash cs3, ok...but are you using actionscript 3.0?

  9. #9
    Junior Member Settled In cangrejero is on a distinguished road
    Join Date
    Aug 2008
    Posts
    4
    Rep Power
    0

    Re: mailTo method

    Onsitus ... I know I am using CS3 because that's what the splash screen says. I have no idea what version of AS was used on the original template. Honestly ... other than being able to turn on my PC with either hand, I can't do much more. Any guidance is appreciated. I am willing to learn. Take care and thanks!

  10. #10
    Junior Member Settled In Grains is on a distinguished road
    Join Date
    Jan 2009
    Posts
    1
    Rep Power
    0

    Re: mailTo method

    I'm dealing with Lotus Notes and a long body text. If the QUERY_STRING is more than about 255 characters, Lotus Notes will not open a new email window.

    I can also break your demo above for Outlook buy putting in a very long string of characters in the text area for the body. I suspect that the limit for Outlook is around 1024 characters.

    I have tried to use the POST method and put my body data into a URLVariable without success so far. Do you have a demo on how to do that?

    Here's what I have tried:

    Code:
    var uv:URLVariable = new URLVariable();
    uv.body = codesTA.text;
    var emailURL:URLRequest = new URLRequest("mailto:" + emailTI.text + "?subject=your request")
    emailURL.method="POST"
    emailURL.data = uv;
    emailURL.contentType = "text/plain"
    navigateToURL(emailURL, "_self")
    TIA!
    LGRains

+ Reply to Thread
Page 1 of 2 1 2 LastLast

Similar Threads

  1. fileLoaded Method
    By olicorse in forum Flash English
    Replies: 3
    Last Post: 08-04-09, 02:51
  2. mailto in action script 3
    By derek_z in forum Flash Italiano
    Replies: 2
    Last Post: 02-10-08, 11:10
  3. Funzione mailto
    By matteo78 in forum Actionscript 3.0 base
    Replies: 4
    Last Post: 10-08-08, 06:57
  4. Metodo mailto di Flash CS3
    By Flep in forum Articoli e tutorials
    Replies: 3
    Last Post: 06-03-08, 10:15
  5. getBounds method
    By Flep in forum Tutorials
    Replies: 0
    Last Post: 20-12-07, 05:38

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts