Applescript 按主题删除邮件

Applescript delete mail by subject

有没有办法按主题删除邮件,我正在尝试制作一个 applescript 从我的 'Sent' 邮箱中删除带有特定主题的邮件。我已经用测试邮件尝试了这些脚本:

    tell application "Mail"
    set theMails to every message of (every mailbox whose name is "Sent") whose subject is "Test Mail"
delete theMails
    end tell

和:

tell application "Mail"
set theMails to {every message of inbox "Sent" whose subject is "Test Mail"}
delete theMails
end tell

两个脚本都不起作用,而且我不理解返回的错误,所以找不到解决方案。帮助申请!

下面的代码有效。最好使用单词 "contains" 而不是尝试完全匹配主题

tell application "Mail"
    set theMails to {every message of sent mailbox whose subject contains "Test Mail"}
    delete theMails 
end tell