Hello World Sample App
The Hello World sample app:
- Launches a tab view when the app's icon is clicked.
- Invokes a Yahoo! Mail API from the launched view.
On This Page
Try It Out
See Quick Start to learn how to get the full source for this example, install it, and run it in Yahoo! Mail.
config.xml
This config.xml tells Yahoo! Mail to load your
app's views/main.html in a tab when the app's icon is
clicked.
<?xml version="1.0"?> <openmail_app_config version="2"> <name>Hello World</name> <description>Hello World Sample App</description> <data/> <events> <click> <action> <launch> <view>main.html</view> <target_zone>tab</target_zone> </launch> </action> </click> </events> </openmail_app_config>
<?xml version="1.0"?> <openmail_app_config version="2"> <name>Hello World</name> <description>Hello World Sample App</description> <data/> <events> <click> <action> <launch> <view>main.html</view> <target_zone>tab</target_zone> </launch> </action> </click> </events> </openmail_app_config>
views/main.html
main.html demonstrates how to pull in the Yahoo! Mail
APIs and then use one one of the API calls,
Mail.compose.
When the "Compose" button is clicked, the form invokes Mail.compose,
which will open the mail composer with some fields prepopulated from the
form.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <!-- load local asset yui for ssl support --> <script src="/yahoo/mail/combo?2.9.0/build/yahoo/yahoo-min.js&2.9.0/build/dom/dom-min.js"></script> <script src="http://mail.yimg.com/nq/om/api/1.1.19/om-min.js"></script> </head> <body> <textarea id="body" cols="60" rows="10">Enter some text and press the <b>bold</b> compose button.</textarea> <p/> <button onclick="demoCompose()">compose</button> <input type="checkbox" value="rich" name="rich" id="richtext"/> Rich text <script> function demoCompose(){ var bodyTxt = YAHOO.util.Dom.get('body').value; var richText = YAHOO.util.Dom.get('richtext').checked; var mailBlob = { to: 'hello@to.com', cc: 'hello@cc.com', bcc: 'hello@bcc.com', subject: 'hello world', html: richText, body: bodyTxt }; openmail.Mail.compose( mailBlob ); } </script> </body> </html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <!-- load local asset yui for ssl support --> <script src="/yahoo/mail/combo?2.9.0/build/yahoo/yahoo-min.js&2.9.0/build/dom/dom-min.js"></script> <script src="http://mail.yimg.com/nq/om/api/1.1.19/om-min.js"></script> </head> <body> <textarea id="body" cols="60" rows="10">Enter some text and press the <b>bold</b> compose button.</textarea> <p/> <button onclick="demoCompose()">compose</button> <input type="checkbox" value="rich" name="rich" id="richtext"/> Rich text <script> function demoCompose(){ var bodyTxt = YAHOO.util.Dom.get('body').value; var richText = YAHOO.util.Dom.get('richtext').checked; var mailBlob = { to: 'hello@to.com', cc: 'hello@cc.com', bcc: 'hello@bcc.com', subject: 'hello world', html: richText, body: bodyTxt }; openmail.Mail.compose( mailBlob ); } </script> </body> </html>