Automator / AppleScript 用于处理 Mac Mail 中收到的电子邮件
我正在设计一个应用程序,允许用户在我的应用程序崩溃时通过电子邮件向我发送崩溃报告。我想让 Mac Mail 在计算机上运行,当收到电子邮件时,会运行自动脚本/AppleScript 来处理电子邮件正文的内容。
我已经在 python 脚本中完成了整个解析/处理,但我必须手动将电子邮件的内容复制到文件中,然后在该文件上运行我的解析器。
设置此功能的最佳方法是什么,以便我可以将电子邮件的内容推送到我的解析脚本中?
非常感谢!
I'm designing an app that allows users to email me crash reports if my app ever crashes. I'd like to leave Mac Mail running on a computer and when an email comes through, an automator script / AppleScript runs to process the contents of the body of the email.
I've got the entire parsing/processing done in a python script, except I have to manually copy the contents of the email into a file and then run my parser on that file.
What's the best way to set this up so I can the contents of the email be pushed into my parsing script?
Many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
最简单的方法可能是定义 Mail.app 规则。您可以设置过滤条件来指定要应用规则的一组传入电子邮件,并且您可以指定的规则操作之一是对传入邮件运行 AppleScript。规则通过 Mail.app
Preferences
-> 进行管理规则
。 Apple 提供了 Mac OS X 中的规则操作脚本示例。请查看/Library/Scripts/Mail Scripts/Rule Actions
或在网络上搜索。Probably the simplest approach is to define a Mail.app Rule. You can set up filtering conditions to specify the set of incoming email to apply the rule to and among the rule actions you can specify is one to run an AppleScript on incoming messages. Rules are managed with Mail.app
Preferences
->Rules
. Apple supplies examples of Rule Action scripts with Mac OS X. Look in/Library/Scripts/Mail Scripts/Rule Actions
or search the web.以下是使用邮件规则将电子邮件提取到文件中的脚本:用于消息导出的 MacScripter / Mail 规则脚本. 可能适合您正在做的事情的示例代码。
Here's a script that extracts from email into a file using a mail rule: MacScripter / Mail rule script for message export. Might be good for sample code for what you're doing.
使用 Applescript 编辑器中的字典查看邮件的属性,您将很快能够查看任何邮件消息的属性。这是获取邮件消息内容的快速但肮脏的示例。
修改上面链接的脚本,将输出复制到临时文件,然后将该文件传递给 Python 脚本进行操作。
Use the Dictionary in Applescript Editor to see the properties of mail and you'll quickly be able to see the properties of any mail message. Here's a quick and dirty example of getting the content of a mail message.
Modify the script linked to above that copies output to a temporary file and then pass that file to your Python script to act on.