Javascript 在 html5 网页的电子邮件中附加文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14228703/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 16:05:51  来源:igfitidea点击:

Attaching a file in email in html5 web page

javascripthtmlemail

提问by user1808433

I am attaching file in html web app using following code but it is not working

我正在使用以下代码在 html web 应用程序中附加文件,但它不起作用

 <div class="email_pot">

<a href="mailto:[email protected]?subject=Enhanced Push-to-Talk&attachments=["js/data.js","js/data.js"]"></a>

</div>

For attach file i use following procedure as it is given below

对于附加文件,我使用以下程序,如下所示

      {
      "toEmail": "ToAddressEmail"
      ,"toName": "ToAddressName"
      ,"subject": "SubjectLine"
      ,"body":"BodyText"
      ,"bodyHtml":"HTML Body Text"
      ,"attachments":["AttachmentPath","
      AttachmentPath"],"titleColour":"Hex Colour (i.e.FF0000)"
      }

回答by Tom Sarduy

So, what's your question?I will assume that you are getting some error when you tried to send the email. I have answered a very similar questionbefore:

那么,你的问题是什么?我假设您在尝试发送电子邮件时遇到了一些错误。我之前回答过一个非常相似的问题

According to RFC 2368you can't add an attachment to a message with the mailto: URL schemedue 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 (...) Only the Subject, Keywords, and Body headers are believed to be both safe and useful.

如果任何标头被认为是危险的,解释 mailto URL 的用户代理应该选择不创建消息 (...) 只有主题、关键字和正文标头被认为既安全又有用。

回答by tenifre

Whether you can put a file attached to an e-mail depends on the mailer. (but many mailers can't add attachement file from maito:protocol)

是否可以将文件附加到电子邮件取决于邮件程序。(但很多邮件无法从 maito:protocol 添加附件文件)

I think I was able to put the attachments in some versions of Outlook, perhaps.

我想我也许能够将附件放在某些版本的 Outlook 中。

回答by Nilesh patel

i think this code solve your problem.

我认为这段代码可以解决您的问题。

<div class="email_pot">
<a href="mailto:[email protected]?subject=my subject&body=see attachment&attachment="+"/my_location_virtual_path/myfile.lis"></a>
</div>