0 Replies Latest reply on Sep 14, 2009 2:08 PM by rul987

    Form posting data to email

    rul987

      Hi,

      I have been working on this code and have not been able to make it work. I don't know what is wrong, any input will be appreciated. I have also tried uploading the file on the server but still no email.

      Thanks,

      3 files below form file,coldfusion file, crossdomain file

       

      cf1.mxml

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">


      <mx:Script>
        <![CDATA[
         import mx.events.*;
         import flash.net.*;
         import mx.controls.Alert;
         import mx.rpc.events.FaultEvent;
                import mx.rpc.events.ResultEvent;
        
         private const FORM_URL:String = http://www.mysamplesite.com/formSend.cfc;  
            public function gotoEmail(e:Event):void {
               var u:URLRequest = new URLRequest("mailto:" + urlLink.text);
               navigateToURL(u,"_self");
            }
           
            public function handleResult(event:ResultEvent):void
            {
                   Alert.show( "Thank You", "Alert!", Alert.OK );
                   resetForm();
               }
               public function handleFault(event:FaultEvent):void
               {
                  your_comment.text = event.fault.toString();
               }
           
         private function resetForm():void
         {
          your_name.text = "";
          your_email.text = "";
          your_comment.text = "";
         }

        ]]>
      </mx:Script>
      <mx:HTTPService id="commentForm"
           url="{FORM_URL}"
           method="POST"
           result="handleResult(event)"
           fault="handleFault(event)"
           resultFormat="text">

       

            <mx:request>
               <name>{your_name.text}</name>
               <email>{your_name.text}</email>
              
               <date>{your_name.text} </date>
               <address>{your_name.text}</address>
               <city>{your_name.text}</city>

               <birthday>{your_name.text}</birthday>
               <fathername>{your_name.text}</fathername>
               <mothername>{your_name.text}</mothername>
               <message>{your_name.text}</message>
            </mx:request>
          </mx:HTTPService>
          <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
         
        <mx:Form id="contactForm" visible="true">
         <mx:FormHeading/>
         <mx:FormItem label="Student Name">
          <mx:TextInput id="your_name" width="310"/>
         </mx:FormItem>
         <mx:FormItem label="Your Email">
          <mx:TextInput id="your_email" width="{your_name.width}"/>
         </mx:FormItem>
        
       
        <mx:FormItem label="Date:">
                  <mx:TextInput id="date" />
              </mx:FormItem>
             
        <mx:FormItem label="Students Address:">
                  <mx:TextInput id="address" />
              </mx:FormItem>
             
              <mx:FormItem label="City:">
                  <mx:TextInput id="city" />
              </mx:FormItem>
             
              <mx:FormItem label="Students Birthday:">
               <mx:TextInput id="studentbirthday" />
              </mx:FormItem>
              
               <mx:FormItem label="Father’s (or Guardian’s) Name:">
               <mx:TextInput id="fathername" />
              </mx:FormItem>
             
               <mx:FormItem label="Mother’s (or Guardian’s) Name:">
               <mx:TextInput id="mothername" />
              </mx:FormItem>
             
               <mx:FormItem label="Home Phone:">
               <mx:TextInput id="phone" />
              </mx:FormItem>
                  
             
              <mx:FormItem label="Comment">
          <mx:TextArea id="your_comment" width="{your_name.width}" height="125"/>
        </mx:FormItem>

         <mx:ControlBar width="100%">
                   <mx:Label id="urlLink" click="gotoEmail(event);" text="Email: arul.paul@hotmail.com"/>
                   <mx:Spacer width="100%"/>
                   <mx:Button label="Submit" click="commentForm.send()"/>
         </mx:ControlBar>
        </mx:Form>
      </mx:VBox>

       

      </mx:Application>

      Cold Fusion file

      formSend.cfc

       

      <!--- arul.paul@hotmail.com --->

      <cfmail to="arul.paul@hotmail.com" from="#form.email#" subject="Inquiry from new customer" server="127.0.0.1">

      You have received a message

      Sender's name: #form.name#

      Sender's email address: #form.email#

      date:#form.date#

      city:#form.city#

      Birthday:#form.birthday#

      Father's Name:#form.fathername#

      Mothename :#form.mothername#

      Message:#form.message#

      </cfmail>

       

      crossdomain.xml file

       

      <?xml version="1.0"?>
      <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
      <cross-domain-policy>
      <allow-access-from domain="*" />
      </cross-domain-policy>
      <allow-http-request-headers-from domain="www.mysamplesite.com"
      headers="*">