简体   繁体   English

OS X:打开电子邮件客户端,创建新邮件并将文件添加为附件

[英]OS X: open e-mail client, create new mail and add file as attachment

We want to make it for users of our (Java) application as easy as possible to send bug-logs to us. 我们希望尽可能简单地让我们(Java)应用程序的用户向我们发送错误日志。 First, we imagined to open a bug-report page of our website and prefill an up-load-input field with the path of the file to upload, but this does not work for security reasons. 首先,我们想象打开我们网站的错误报告页面,并预先填写一个上传输入字段,其中包含要上传的文件的路径,但出于安全原因,这不起作用。

Is it possible on OS X (command line call, Apple Script, what ever) to open a new e-mail in the default e-mail client and add a certain file as attachment? 是否可以在OS X(命令行调用,Apple Script,无论如何)中在默认电子邮件客户端中打开新电子邮件并将某个文件添加为附件?

You can do this from the command line (terminal). 您可以从命令行(终端)执行此操作。 Here's an example: 这是一个例子:

open -a Mail filetosend.ext

This opens the Mac Mail app, creates a message and attaches the file, ready to send. 这将打开Mac Mail应用程序,创建一条消息并附加文件,准备发送。

Does it necessarily have to be an attachment? 它一定是附件吗? You could inline text based info in the message body using the bog standard mailto: URL which would work in any OS and any email client. 您可以使用bog标准mailto: URL在邮件正文中内联基于文本的信息,该URL可用于任何操作系统和任何电子邮件客户端。

Unfortunately there's no standard way to attach a file; 不幸的是,没有标准的方法来附加文件; you'd have to write a separate script for any of the many email clients the user has installed, and that's assuming they actually use an email client—many people use Gmail, for example. 您必须为用户安装的许多电子邮件客户端编写单独的脚本,并假设他们实际使用的是电子邮件客户端 - 例如,许多人使用Gmail。

If you can't encode the information in text, you can just submit the report by HTTP(S) yourself. 如果您无法在文本中对信息进行编码,则可以自己通过HTTP(S)提交报告。 There are several open source frameworks that can help with this, such as FeedbackReporter (which uses HTTP) and UKFeedbackProvider (for email). 有几个开源框架可以帮助解决这个问题,例如FeedbackReporter (使用HTTP)和UKFeedbackProvider (用于电子邮件)。

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

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