如何在Apple邮件中运行简单的AppleScript?

问题描述 投票:2回答:1

我似乎正在努力让一个简单的脚本运行。

我的脚本现在没有做太多工作,只需通过电子邮件循环并获取发件人的电子邮件和姓名。

using terms from application "Mail"
    on perform mail action with messages these_messages for rule this_rule
        tell application "Mail"
            set the message_count to the count of these_messages
            repeat with i from 1 to the message_count
                set this_message to item i of these_messages
                tell (sender of this_message)
                    set theFromName to (extract name from it)
                    set theFromAddress to (extract address from it)
                end tell
                log "joel was here"


            end repeat
        end tell
    end perform mail action with messages
end using terms from

当我尝试添加规则来运行此脚本时,我进入文件选择器,当我选择文件时没有任何反应,它只是在脚本编辑器中将文件打开到一个新窗口。我的文件以.scpt结尾,我已经尝试将它放在com.apple.mail文件夹中,在那里的子文件夹中,也在原始位置(在ScriptEditor文件夹中),似乎没有任何效果。

这一定是愚蠢和基本的,任何想法?

还有任何实用的方法来测试这个脚本,从我用google搜索日志将无法正常工作。

enter image description here

applescript apple-mail
1个回答
0
投票

我终于想通了,它必须在以下的根目录:〜/ Library / Application Scripts / com.apple.mail

它不能在子文件夹中,我的名字中也有一个“ - ”,这可能是一个问题。

一旦我这样做,脚本就会在下拉列表中列出。

© www.soinside.com 2019 - 2024. All rights reserved.