Question

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

Was it helpful?

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,
  }
});

OTHER TIPS

It looks like you can set attachments through data.blobs and data.filenames, and misc content (to, subject, content) through data.URI.

Detauls about the mailto: syntax can be found in the MDN entry on Email links.

Regards,

Edit May 2014

As the mail app was refactored, I've dropped the old broken code link in favour of MDN docs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top