Search code examples
firefox-oswebintents

Send email from FirefoxOS app with content


I'm trying to send an email from a FirefoxOS App to share content generated by it.

Currently I'm using:

var createEmail = new MozActivity({
  name: "new",
  data: {
    type : "mail",
  }
});

But I haven't been able to find any way of appending or attaching content to this email


Solution

  • Thanks to @sebasmagri answer I learnt that the "mailto" URI accepts many more fields than I knew about. Specially interesting is the body and subject:

    mailto:someone@example.com?
    cc=someone_else@example.com
    &subject=This%20is%20the%20subject
    &body=This%20is%20the%20body
    

    This allows me to set the different parts of the email as I wanted to.

    The final code looks like:

    var body = encodeURIComponent(JSON.stringify(event.target.result));
    var createEmail = new MozActivity({
      name: "new",
      data: {
        type : "mail",
        url: "mailto:?subject=FiREST%20Request&body=" + body,
      }
    });