将AppleScript应用于Mail中的特定电子邮件

时间:2012-08-15 09:45:37

标签: email applescript

我有一个AppleScript我想申请个别电子邮件(将它们存档为具有特定文件名的PDF),但无法解决如何将其应用于特定电子邮件的问题。

我无法设置邮件规则来运行脚本,因为我只是想判断是否要将一个邮件归档邮件。尝试将其设置为“服务”,但右键单击“邮件”中的电子邮件时没有“服务”菜单。

有什么建议吗?!

1 个答案:

答案 0 :(得分:0)

您打算如何指定哪些电子邮件?如果通过手动选择它们,您可以“获得选择”。这是一个简单的脚本,它将获取每个所选消息的主题和消息ID。

tell application "Mail"
    set mySelection to get selection
    set eMails to {}
    repeat with selectedMessage in mySelection
        set messageId to selectedMessage's message id as string
        set eMail to selectedMessage's subject & ": " & messageId
        tell me to set end of eMails to eMail
    end repeat
    set AppleScript's text item delimiters to "\n\n"
    set the clipboard to (eMails as string)
end tell

将其保存在〜/ Library / Scripts / Applications / Mail /中,它将显示在“脚本”菜单中。您可能必须将AppleScript编辑器的设置转到“在菜单栏中显示脚本菜单”才能显示“脚本”菜单。

(注意:编译此脚本时,\ n \ n将变为新行。)