2012-02-11 78 views
0

我写了一个由邮件规则调用的脚本。我希望脚本在特定条件下将邮件移动到垃圾箱。它没有工作,所以我已经评论了测试,但它仍然无法正常工作。我从一个在线教程中获得了代码。该教程将消息移至“归档”。当我将这个调用替换为垃圾时,该规则本身起作用。下面是我测试:使用AppleScript将邮件移动到垃圾箱

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编辑器模板。

感谢, 柯特

附:是否有任何书籍处理Apple Mail和MailScript?

+0

你可以尝试简单的'移动this_message到邮箱“废纸篓”' - 但显然别人也有今天邮寄脚本问题:AppleScript的移动邮件后,中止执行(HTTP://计算器.com/questions/9243825) – Flambino 2012-02-12 00:58:57

回答

2

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

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

而不是试图将消息“移动”到垃圾箱,您应该只说 delete this_message。然后

Mail.app会根据您的帐户设置进行(Mail偏好>帐户>(帐户)>邮箱行为>垃圾)和移动邮件到其帐户的垃圾邮箱或其他根据您的设置立即删除它。

+0

我已经解决了我自己的问题。你的方法也可能工作 – curt 2012-02-13 21:05:00

相关问题