javascript 按下按钮,启动带有附件的本机电子邮件程序(位于网络服务器上)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8657888/
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
Press button, start native email program with attachment (located on webserver)
提问by Chizpa
I have tried all different versions of send email however I have not yet achieved the following:
我已经尝试了所有不同版本的发送电子邮件,但是我还没有达到以下目标:
Javascript (or HTML) button, when pressed, open native mail application with attachment. The attachment is located on the same server as the webpage ex.:
Javascript(或 HTML)按钮,按下时,打开带有附件的本机邮件应用程序。附件与网页位于同一服务器上,例如:
- web:
www.something.com
- file:
www.something.com/file.pdf
- 网络:
www.something.com
- 文件:
www.something.com/file.pdf
The solution should not include serverside scripting (ASP/PHP) I need a simple snippet to make this happen :) Any help would be greatly appreciated.
该解决方案不应包括服务器端脚本 (ASP/PHP) 我需要一个简单的片段来实现这一点:) 任何帮助将不胜感激。
回答by Rebecca
There is no standardized way to do this, but some email clients accept:
没有标准化的方法可以做到这一点,但一些电子邮件客户端接受:
a href="mailto:[email protected]?attachment=<your filepath>"
where would have to be something like "C://Inetpub/wwwroot/myfile.pdf"
哪里必须是“C://Inetpub/wwwroot/myfile.pdf”之类的东西
However, it will only attach something from the client's machine. You can't attach a file from the web.
但是,它只会从客户端的机器上附加一些东西。您无法附加来自网络的文件。
Another option would be to just include a link to the file in the body of your email, or instructions to the user on how to email their attachment.
另一种选择是在您的电子邮件正文中包含指向该文件的链接,或者向用户提供有关如何通过电子邮件发送其附件的说明。
回答by Uri Goren
This might not be what you're looking for, but you can send arguments to native e-mail client using the "mailto:" reference.
这可能不是您要查找的内容,但您可以使用“mailto:”引用向本机电子邮件客户端发送参数。
For example, you can set the default subject with:
例如,您可以设置默认主题:
<a href="mailto:[email protected]?subject=complaint">
<a href="mailto:[email protected]?subject=complaint">
see more at: http://msdn.microsoft.com/en-us/library/aa767737%28v=vs.85%29.aspx
查看更多信息:http: //msdn.microsoft.com/en-us/library/aa767737%28v=vs.85%29.aspx
so you can send the link to the attachment with
这样您就可以将链接发送到附件
<a href="mailto:[email protected]?body=the attached file is at this link: %link%">
<a href="mailto:[email protected]?body=the attached file is at this link: %link%">