0

我编写了一个由邮件规则调用的脚本。我希望脚本在某些条件下将邮件移动到垃圾箱。它没有用,所以我已经注释掉了测试,它仍然没有用。我从在线教程中获得了代码。本教程将消息移至“归档”。当我用移动到垃圾箱替换对脚本的调用时,规则本身就起作用了。这是我正在测试的内容:

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

            --              try
            --                  set this_content to (every character of content of this_message) as Unicode text
            --                  if this_content is in {"", "?"} then error
            -- if "bowles" is not in this_content and "patton" is not in this_content then
            set mailbox of this_message to mailbox "Trash"
            -- end if
            --              on error error_message
            --                  set this_content to "NO CONTENT"
            --              end try
        end repeat
    end tell
end perform mail action with messages

结束使用条款

有争议的声明是:将this_message的邮箱设置为邮箱“垃圾箱”

其余的活动代码来自 AppleScript Editor 模板。

谢谢,柯特

PS 有没有关于使用 AppleScript 和 Mail 的书?

4

2 回答 2

4

与其尝试将消息“移动”到垃圾箱,不如说 delete this_message.

然后,Mail.app 将根据您的帐户设置(邮件首选项>帐户>(您的帐户)>邮箱行为>垃圾箱)继续并将邮件移动到其帐户的垃圾箱邮箱,或者立即将其删除,具体取决于您的设置。

于 2012-02-13T14:21:38.887 回答
3

在问这里之前,我应该进行更广泛的网络搜索。希望这个答案对其他人有用。我在下面添加了第一行,并从上面的代码中修改了第二行。

        set theAccount to account of mailbox of this_message
        set mailbox of this_message to mailbox "Trash" of theAccount
于 2012-02-13T21:03:26.600 回答