Applescript将电子邮件移动到垃圾箱,但不从服务器中删除

Applescript将电子邮件移动到垃圾箱,但不从服务器中删除,applescript,apple-mail,Applescript,Apple Mail,我写了一个应用程序脚本,将选定的电子邮件移动到垃圾箱。剧本在这方面做得很好。问题是,电子邮件仍保留在服务器上。我需要添加额外的代码来实现这一点吗?代码如下: 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

我写了一个应用程序脚本,将选定的电子邮件移动到垃圾箱。剧本在这方面做得很好。问题是,电子邮件仍保留在服务器上。我需要添加额外的代码来实现这一点吗?代码如下:

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 message_count to 1 by -1
            set this_message to item i of these_messages
            set this_content to (every character of content of this_message) as Unicode text
            if "bowles" is not in this_content and "patton" is not in this_content then
                set theAccount to account of mailbox of this_message
                set mailbox of this_message to mailbox "Trash" of theAccount
            end if
        end repeat
    end tell
end perform mail action with messages
end using terms from

如果不查看整个脚本和其他可能导致问题的规则,则很难排除故障。尝试将停止评估规则操作添加到您的规则:

using terms from application "Mail"
on perform mail action with messages these_messages for rule this_rule
    tell application "Mail"
        repeat with this_message in these_messages
            set this_content to content of this_message
            if "bowles" is not in this_content and "patton" is not in this_content then
                set theAccount to account of mailbox of this_message
                set junk mail status of this_message to false
                set mailbox of this_message to mailbox "Trash" of theAccount
            end if
        end repeat
    end tell
end perform mail action with messages
end using terms from


不幸的是,答案似乎是为电子邮件源创建一个单独的规则。最后,我只是取消了邮件列表的订阅,因为我已经多年没有从他们那里看到任何有用的信息了

你在使用pop、imap、exchange吗?这是一个pop服务器:goDaddy。我有一个删除其他电子邮件的规则。把项目留在服务器上没有问题,我试着注释代码的各个部分。是上面的第二行代码导致了问题。我甚至将它移动到另一个脚本,该脚本由另一个规则执行。电子邮件仍在服务器上。我设计了一个解决方法。在按第一条规则运行的Applescript中,我将所选邮件设置为垃圾邮件。然后,我添加了第二条规则,将所有设置为垃圾邮件的邮件移至垃圾箱。问题是邮件应用程序将一些邮件设置为垃圾邮件,但这些邮件不是垃圾邮件。让脚本干净地运行仍然很好。所有其他邮件都将从服务器上删除,因此我认为前两个命令没有任何帮助。似乎邮件在从服务器上删除之前必须先进入收件箱。单一规则是行不通的。整个过滤器是(A或B或C或D)和(不是E或不是F)。第一部分是调用脚本的规则。根据我所能说的,规则必须是所有的AND或or。我可以分解成四个独立的规则,但我可能有更复杂的过滤器,我想学习AppleScript。正如我在第一篇帖子的评论中提到的,我确实想出了一个解决办法。