Search code examples
titaniumtitanium-mobiletitanium-alloy

How to open email composer with attachment in titanium?


I am making application in IOS and Android using titanium .I want to open email composer (having some attachment) on button click.can you please tell me how can I do in IOS and Android.?

Thanks


Solution

  • Directly from the documentation. This assumes you already have created your button.

    button.addEventListener('click', function(e) {
        // Create email window
        var emailDialog = Ti.UI.createEmailDialog();
        emailDialog.subject = "Hello from Titanium";
        emailDialog.toRecipients = ['foo@yahoo.com'];
        emailDialog.messageBody = '<b>Appcelerator Titanium Rocks!</b>';
        // Add attachment
        var f = Ti.Filesystem.getFile('cricket.wav');
        emailDialog.addAttachment(f);
        // Open the window
        emailDialog.open();
    });