Send email from FirefoxOS app with content

天大地大妈咪最大 提交于 2019-12-07 13:55:55

问题


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


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/16914627/send-email-from-firefoxos-app-with-content

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