Create Email

The URLRequest class can be used to open the Messaging application to send text messages. By prepending the request with mailto:, you will tell Android to 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-5 shows the sample application running, Figure 6-6 shows the email selection window being launched after the Send button has been clicked, and Figure 6-7 shows the properties being pre-populated 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[
protectedfunction sendIt_clickHandler(event:MouseEvent):void
{
vars: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=”160″ text=”rtretola@gmail.com”
width=”250″/>
<s:Label text=”Subject” top=”100″ left=”50″/>
<s:TextInput id=”subject” top=”90″ left=”160″ text=”hello” width=”250″/>
<s:Label text=”Message” top=”160″ left=”50″/>
<s:TextInput id=”message” top=”150″ left=”160″ width=”250″/>
<s:Button id=”sendIt” label=”Send” click=”sendIt_clickHandler(event)” top=”210″
left=”160″/>
</s:Application>

A sample Email application

The email selector after clicking Send

Message properties set within Gmail


Posted

in

by

Tags: