4 Replies Latest reply on Nov 30, 2006 1:47 PM by moros3

    flex 2 email!

      Hello all,

      I've searched for how to do this on the forums already, but nothing was especially helpful. I'm trying to build an application that consists of multiple forms and a two trees. Also, there is a button labeled "send email".

      How can it be set up so that once the button is clicked, the user-inputted data in the forms(one of the forms asking for the user's e-mail address) AND the currently selected items in both trees are sent to both: 1. the user's inputted email & 2. a specified e-mail address of the application builder's choosing?

      Can this be done? Would it use PHP? or perhaps CGI/Perl? I do not have ColdFusion as an option.

      Any help on this problem would be greatly appreciated. I'm sure the community would love to hear a solution as well.
        • 1. Re: flex 2 email!
          davidmedifit Level 1
          Let me see if I have this right - the Flex app collects the information, and when the user has inputted required fields on the app, they will press the "send email" button - this will echo the inoutted info on the flex app to the user, via email.

          What you will need to do is pass that information to a back end system that will send the email. If you do NOT have ColdFusion or Java available, you will need to pass the information via a web service (you should see good examples of how to use web services on this forum, reply here if you can't find any), and pass the form information as variables.

          You may have alot of forms fields to pass, in which case investigate the mx:model tag and see if you can pass a single parameter to the web service - can anyone else advise on the use of mx:model in this situation?

          If you need to send the email to a default (system generated) email, you will code that email address on the backend.

          Reply if I can assist more.


          • 2. Re: flex 2 email!
            chris.huston.t10 Level 3
            If you can use PHP, then it is fairly simple to do:

            $recipient1 = $_POST['recipient1'];
            $subject = $_POST['subject'];
            $message = $_POST['message'];
            $headers = 'From:'. $_POST['sender']. "\r\n" .
            'Reply-To: '.$_POST['reply'] . "\r\n" .
            'X-Mailer: PHP/' . phpversion();

            $recipient2 = $_POST['recipient2'];
            mail($recipient1, $subject, $message, $headers);
            mail($recipient2, $subject, $message, $headers);

            Then in your Flex app, send the form data using a HTTPService call.

            private function send_email():void {
            var params:Object = new Object();
            params.recipient1 = recipient1.text;
            params.recipient2 = recipient2.text;
            params.message = message.text;

            url=" http://www.yourserver.com/send_email.php"

            I think this will work for you, but post back if you need something different.

            • 3. Re: flex 2 email!
              ntsiii Level 3
              Hey, David and all.

              I personally do not like mx:Model because it is a bit of a black box: I have trouble predicting how it will convert complex xml into the nested object structure. Instead, and this is preferred by Adobe, use e4x XML.

              Also, when David says "web service" I think he intends to include HTTPService. (And as Vygo advises) HTTPService is simply XML over HTTP, sometimes called REST and is the protocol used by many "ajax" apps. HTTPService is much easier to use than SOAP-based "WebService", and is somewhat faster. Just have you server page set the contentType to "text/xml", and write the xml string out in the response.

              • 4. Re: flex 2 email!
                moros3 Level 1
                Thanks for all of your help, I'll try out the methods you mentioned.