简体   繁体   English

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

[英]Apply an AppleScript to a Specific Email Message in Mail

I have an AppleScript I want to apply to individual emails (to archive them as PDFs with a particular file name), ut can't work out how to apply it to specific emails. 我有一个AppleScript,我想将其应用于单个电子邮件(将它们归档为具有特定文件名的PDF),但是无法确定如何将其应用于特定的电子邮件。

I can't set up a mail rule to run the script as it is just my judgment as to whether I want to archive one out of Mail or not. 我无法设置邮件规则来运行脚本,因为这只是我判断是否要从Mail中存档一个邮件规则。 Have tried setting it up as a Service, but there is no Services menu on right clicking an email in Mail. 尝试将其设置为服务,但是右键单击“邮件”中的电子邮件没有“服务”菜单。

Any suggestions?! 有什么建议么?!

Rich 丰富

How are you planning on specifying which individual emails? 您如何计划指定哪些电子邮件? If by selecting them manually, you can “get selection”. 如果通过手动选择它们,则可以“获取选择”。 Here's a simple script that will get the subject and message Id of each selected message. 这是一个简单的脚本,它将获取每个选定消息的主题和消息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

Save it in ~/Library/Scripts/Applications/Mail/ and it will show up in your Scripts menu. 将其保存在〜/ Library / Scripts / Applications / Mail /中,它将显示在“脚本”菜单中。 You may have to go to AppleScript Editor's settings to “Show Script menu in menu bar” to make the Scripts menu show up. 您可能必须转到AppleScript编辑器的设置以“在菜单栏中显示脚本菜单”才能显示“脚本”菜单。

(Note: when you compile this script, the \\n\\n will turn into new lines.) (注意:编译此脚本时,\\ n \\ n会变成新行。)

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

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