问题
We want to make it for users of our (Java) application as easy as possible to send bug-logs to us. 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?
回答1:
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.
If you can't encode the information in text, you can just submit the report by HTTP(S) yourself. There are several open source frameworks that can help with this, such as FeedbackReporter (which uses HTTP) and UKFeedbackProvider (for email).
回答2:
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.
回答3:
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.
来源:https://stackoverflow.com/questions/5351541/os-x-open-e-mail-client-create-new-mail-and-add-file-as-attachment