Send email from FirefoxOS app with content

会有一股神秘感。 提交于 2019-12-06 01:49:49

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!