O'Reilly logo

Appcelerator Titanium Smartphone App Development Cookbook - Second Edition by Jason Kneen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding attachments to an e-mail

Now we have a basic e-mail dialog up and running, but ideally what we want to do is attach the photo that we selected from our Photo Gallery to our new e-mail message. Luckily for us, Titanium makes this easy by exposing the Ti.UI.createEmailDialog()method, which accepts the local path of the file we want to attach.

How to do it...

Adding an attachment is usually as simple as passing the location of the file or blob you wish to attach to the addAttachment() method of emailDialog. For example:

//add an image from the Resource/images directory
    emailDialog.addAttachment(Ti.Filesystem.getFile('/images/my_test_photo.jpg'));

Our case is a bit trickier than this, though. In order to successfully attach our chosen image, we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required