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

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

问题描述

我已经写了一个由邮件规则调用的脚本。我希望脚本邮件移动到垃圾箱在一定条件下。它没有工作,所以我注释掉的测试,它仍然没有奏效。我从一个在线教程中的code。本教程移到提起的消息。规则本身工作时,我更换了调用脚本移动到回收站。下面是我测试:

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"

活动code的其余部分是从AppleScript的编辑器模板。

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

谢谢,
柯特

P.S。是否有任何书籍,在那里,处理使用AppleScript使用邮件?

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

推荐答案

我应该问这里做过一个更广泛的网络搜索。希望这个答案将是对别人有用。我加入了第一线以下,修改从上面的code中的第二个。

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天全站免登陆