Flex: Simple Send Mail Application


/ Published in: MXML
Save to your folder(s)

Quick example on how to do a POST request using Flex and the HTTPService class


Copy this code and paste it in your HTML
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
  3. <!--
  4. A. HTTPService is used to send the Message
  5. -->
  6. <mx:HTTPService id="sm" url="http://localhost:8081/sendmail"
  7. useProxy="false" method="POST" resultFormat="e4x">
  8. <mx:request xmlns="">
  9. <msgFrom>
  10. {msgFrom.text}
  11. </msgFrom>
  12. <msgTo>
  13. {msgTo.text}
  14. </msgTo>
  15. <msgSubject>
  16. {msgSubject.text}
  17. </msgSubject>
  18. <msgBody>
  19. {msgBody.text}
  20. </msgBody>
  21. </mx:request>
  22. </mx:HTTPService>
  23. <mx:Panel layout="horizontal" horizontalAlign="center" verticalAlign="middle">
  24. <mx:VBox>
  25. <mx:Label text="Flex Client for Google App Engine" fontSize="15" fontWeight="bold"/>
  26. <!--
  27. B. Form
  28. -->
  29. <mx:Form defaultButton="{sendMessage}" width="419">
  30. <mx:Label text="Compose a Mail Message"/>
  31. <mx:FormItem label="From">
  32. <mx:TextInput id="msgFrom" width="300" text=""/>
  33. </mx:FormItem>
  34. <mx:FormItem label="To">
  35. <mx:TextInput id="msgTo" width="300" text=""/>
  36. </mx:FormItem>
  37. <mx:FormItem label="Subject">
  38. <mx:TextInput id="msgSubject" width="300" text=""/>
  39. </mx:FormItem>
  40. <mx:FormItem label="Body">
  41. <mx:TextArea id="msgBody" width="300" height="100" text=""/>
  42. </mx:FormItem>
  43. <mx:FormItem>
  44. <mx:Button id="sendMessage" label="Send" click="{sm.send()}"/>
  45. </mx:FormItem>
  46. </mx:Form>
  47. <!--
  48. C. Previously Sent Messages Data Grid
  49. -->
  50. <mx:Label text="Previously Sent Messages"/>
  51. <!--
  52. D. DataProvider is expecting to receive XML. It is BOUND to
  53. -->
  54. <mx:DataGrid id="dg" dataProvider="{sm.lastResult.message}">
  55. <mx:columns>
  56. <mx:DataGridColumn headerText="From" dataField="from"/>
  57. <mx:DataGridColumn headerText="To" dataField="to"/>
  58. <mx:DataGridColumn headerText="Date" dataField="date"/>
  59. <mx:DataGridColumn headerText="Subject" dataField="subject"/>
  60. <mx:DataGridColumn headerText="Body" dataField="body"/>
  61. </mx:columns>
  62. </mx:DataGrid>
  63. </mx:VBox>
  64. </mx:Panel>
  65. </mx:Application>

URL: http://www.colettas.org/?p=240

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.