3

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

Eldelshell
  • 6,683
  • 7
  • 44
  • 63

2 Answers2

4

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,
  }
});
Eldelshell
  • 6,683
  • 7
  • 44
  • 63
3

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.

sebasmagri
  • 170
  • 2
  • 10
  • Yes, this code also includes a reference to set the body. I'll see if I can make it work with any of the two options, although I don't really want to use an attachment. Thanks anyway. – Eldelshell Jun 11 '13 at 13:45