使用 AppleScript 将邮件移至垃圾箱 [英] Using AppleScript to Move Mail Messages to Trash

查看:37
本文介绍了使用 AppleScript 将邮件移至垃圾箱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I've written a script that is invoked by a Mail rule. I want the script to move messages to the trash under certain conditions. It didn't work so I've commented out the test and it still didn't work. I got the code from an online tutorial. The tutorial moved the message to "Filed". The rule itself worked when I replaced the call to the script with a move to the trash. Here's what I'm testing:

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的邮箱设置为邮箱垃圾箱"

The statement at issue is: set mailbox of this_message to mailbox "Trash"

其余的活动代码来自 AppleScript 编辑器模板.

The rest of the active code was from AppleScript Editor template.

谢谢,短片

附言有没有关于在邮件中使用 AppleScript 的书籍?

P.S. Are there any books out there that deal with using AppleScript with Mail?

推荐答案

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

I should have done a more extensive Web search before asking here. Hopefully, this answer will be useful to others. I added the first line below and modified the second one from the code above.

        set theAccount to account of mailbox of this_message
        set mailbox of this_message to mailbox "Trash" of theAccount

这篇关于使用 AppleScript 将邮件移至垃圾箱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆