在 Firefox 中通过 JavaScript 打开 Outlook
我想从 Javascript 打开 Outlook,它用于内部应用程序,不会访问网络。客户使用的是IE,Firefox和Outlook都会安装,安全性不是问题。
在这种情况下,“mailto:”还不够,因为要求是我需要将文件附加到邮件中,似乎不能通过使用“mailto:”来完成此操作(找到了一些旧的论坛条目,但我尝试过的任何方法都不起作用,并且 mailto URL 方案 似乎并未正式生效支持一下)。 但是,在 IE 中我可以使用 ActiveX:
var outlookApp = new ActiveXObject("Outlook.Application");
然后我可以使用它,添加正文,添加附件等等,完美。
在 Firefox 中,这样的事情可能发生吗?
我已经知道 tiddlywiki 做了一些非凡的事情,因为它可以以某种方式在硬盘上保存自己。所以我查看了源代码,发现了这个:
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
更新: 好吧,读完之后我想我可以回答我的一个问题:不,这种方法行不通,因为实现 XPCOM 的 Mozilla API 不支持打开外部程序之类的功能。 仍然留下一个问题:还有其他想法吗?
I want to open Outlook from Javascript, it's for an internal application, nothing that will ever hit the web. The customer is using IE and Firefox and Outlook will be installed, security is not an issue.
"mailto:" just isn't sufficient in this case, since the requirement is that I need to attach a file to the mail, it seems that this cannot be done by using "mailto:" (found some old-ish forum entries, but nothing of what I tried worked and it seems that the mailto URL scheme doesn't officially support it).
But, in IE I can use ActiveX:
var outlookApp = new ActiveXObject("Outlook.Application");
and then I can mess around with it, add a body, add attachments and so on, perfect.
Is something like this possible in any way in Firefox?
What I already knew was that tiddlywiki does some extraordinary things, in that it can save itself somehow on the harddisk. So I looked at the source and found this:
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Which, as I understand gives the Script access to the Browser API/XPConnect/XPCOM. But now I'm stuck. How would I actually open an Outlook object? Would this even be a working approach? I'm not sure. Maybe any other ideas? Any advice would be appreciated.
Update:
ok, after some reading I think I can answer one of my questions with: No, this approach won't work, since the Mozilla API that's implementing XPCOM doesn't support anything like opening an external program.
Still leaves the question: Any other ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
回答我自己的问题:忽略规范,这是一个坏主意。
它可以通过 Firefox 中的 ActiveX 插件来解决,但实际上,由于安全问题,最好不要这样做,即使它只是一个内部应用程序。需要更改某些浏览器设置才能使类似功能正常工作,这是有风险的。最后,该规范包含一个非用例:“单击按钮后,打开 Outlook 以通过电子邮件发送附件”。愚蠢的是,除了可以访问内部网络中的文件的其他员工之外,实际上没有任何人可以允许员工向其发送文件,因此仅发送要容易得多(并且也可以安全地实现)文件的链接。
Answering my own question with this: Ignore the spec, it's a bad idea.
It could be solved with an ActiveX Plugin in Firefox, but actually it's far better to just not do something like that because of security issues, even if it is only an internal application. Some browser settings need to be changed to get something like that to work, which is risky. And finally, the spec contained a not-use-case here: "upon click of a button, open outlook to send an attached file via email". The stupid thing is, that there's actually nobody whom the employees would be allowed to send the file to, apart from other employees which can access the file in the internal network, so it's far easier (and can also be securily implemented) to just send a link to the file.