Search code examples
javascripthtmlmozillafirefox-os

Is there any way to Pre-fill e-mail body in Firefox OS


Hi i want to know that is there any activity from where i can fill the email activity and start it from my program.. like this...enter image description here


Solution

  • To populate a subject, cc, bcc and/or body, simply append this information onto the mailto url:

    data: {
        type : "mail",
        url: "mailto:[email protected]?subject=this%20is%20a%20test&[email protected]",
    }
    

    Regarding how to include an attachment, that depends on which version of Firefox OS you want your app to be compatible with.

    As of Firefox OS 1.2, you can simply add blobs and filenames objects to the data object:

    data: {
        type : "mail",
        url: "mailto:[email protected]?subject=this%20is%20a%20test&[email protected]",
        blobs: [testBlob],
        filenames: ['test.html']
    }
    

    I've updated the Firefox OS Boilerplate app to include a working example of this. The related bits of Firefox OS code can be found in apps/email/js/app_messages.js and apps/email/js/mail_app.js.

    Prior to Firefox 1.2, the new (mail) activity does not accept these parameters and you'll need to use the share activity:

    var sharingImage = new MozActivity({
        name: "share",
        data: {
            type: "image/*",
            number: 1,
            blobs: [blob]
        }
    });
    

    The Firefox OS Boilerplate includes a working example of the share activity.

    The relevant code showing that attachments are limited to the share activity in version 1.1 is in apps/email/js/mail-app.js.