Create Email

The URLRequest class can be used to open the Messages application to send text messages. By prepending the request with mailto:, iOS will launch the Email application when the navigateToURL method is called. There are several properties that can be passed into the URLRequest to set the send-to email address, the email subject, and the email message.

Figure 6-4 shows the sample application running, Figure 6-5 shows the email selection window being launched after the Send button has been clicked, and Figure 6-6 shows the properties being prepopulated in the Gmail application:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                  xmlns:s="library://ns.adobe.com/flex/spark">

    <fx:Script>
          <![CDATA[
               protected function sendIt_clickHandler(event:MouseEvent):void
               {
                     var s:String = "";
                     s += "mailto:";
                     s+= sendTo.text;
                     s+= "?";
                     s+= "subject=";
                     s+= subject.text;
                     s+= "&";
                     s+= "body=";
                     s+= message.text;
                     navigateToURL(new URLRequest(s)); } ]]> </fx:Script> <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <s:Label text="Send To" top="40" left="50"/> <s:TextInput id="sendTo" top="30" left="200" text="rtretola@gmail.com" width="300"/> <s:Label text="Subject" top="120" left="50"/> <s:TextInput id="subject" top="110" left="200" text="hello" width="300"/> <s:Label text="Message" top="200" left="50"/> <s:TextInput id="message" top="190" left="200" width="300"/> <s:Button id="sendIt" label="Send" ...

Get Developing iOS Applications with Flex 4.5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.