简体   繁体   English

使用 javascript 将 HTML5 WebSQL 数据库的内容附加到电子邮件

[英]Attach content of HTML5 WebSQL database to email using javascript

I have created local DB (WebSQL) in HTML5.我在 HTML5 中创建了本地数据库(WebSQL)。 The content of the local storage has to be sent as an attachment in an email.本地存储的内容必须作为电子邮件中的附件发送。 The email client will be opened using javascript mailto feature.电子邮件客户端将使用 javascript mailto 功能打开。

The requirement is when the email client opens it should have the content of the local storage attached as a file (in any file format like xml, csv or text) in the email client window.要求是当电子邮件客户端打开时,它应该在电子邮件客户端窗口中将本地存储的内容作为文件(以任何文件格式,如 xml、csv 或文本)附加。

As I understand, the content will have to be exported to a file first and then attached to email.据我了解,内容必须先导出到文件,然后附加到电子邮件中。 Can this be done using File API of HTML5?这可以使用 HTML5 的文件 API 来完成吗?

My question is - Is it possible to do this using javascript?我的问题是 - 是否可以使用 javascript 来做到这一点?

EDIT: My problem is that it has to be done entirely on the client side.编辑:我的问题是它必须完全在客户端完成。 Is there at least a way to export the local db content into a file using javascript?是否至少有一种方法可以使用 javascript 将本地数据库内容导出到文件中? This file then can be manually attached to the email.然后可以将此文件手动附加到电子邮件中。

I will assume that you are talking about do something like this (after extract the info from the WebSQL):我会假设你正在谈论做这样的事情(从 WebSQL 中提取信息之后):

document.location = "mailto:"+recipient+"?attach="+"attach.zip";

According to RFC 2368 you can't add an attachment to a message with the mailto: URL scheme due security reasons:根据RFC 2368 由于安全原因,您不能使用 mailto: URL 方案向邮件添加附件

The user agent interpreting a mailto URL SHOULD choose not to create a message if any of the headers are considered dangerous;如果任何标头被认为是危险的,解释 mailto URL 的用户代理应该选择不创建消息; it may also choose to create a message with only a subset of the headers given in the URL.它还可以选择仅使用 URL 中给出的标头的子集来创建消息。 Only the Subject, Keywords, and Body headers are believed to be both safe and useful.只有主题、关键字和正文标题被认为既安全又有用。

Conclusion:结论:

mailto: only supports header values or text/plain content. mailto:仅支持标题值或文本/纯文本内容。

Alternatives:备择方案:

  • If you are using PHP you can do this using PHPMailer如果您使用的是 PHP ,则可以使用PHPMailer执行此操作

  • If you are using C# you can use this class如果你使用 C# 你可以使用这个类

  • For any other server side language I'm 99% sure that there is a way to do this.对于任何其他服务器端语言,我 99% 肯定有办法做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM