如何使用AppleScript从Mail中选择消息列表

时间:2016-04-05 14:36:59

标签: applescript

这有效:

tell application "Mail"
set x to every message in inbox whose subject contains "deal"
end tell

现在我想使用当前选择做同样的事情,但这不起作用:

tell application "Mail"
set x to every message in selection whose subject contains "deal"
end tell

收到错误"邮件收到错误:无法完成选择的主题包含\"处理\"到类型说明符。"编号-1700到说明符

我错过了什么?

1 个答案:

答案 0 :(得分:2)

很遗憾,您无法在whose属性上使用selection子句。

解决方法是重复循环

tell application "Mail"
    set theMessages to selection
    set filteredMessages to {}
    repeat with aMessage in theMessages
        if subject of aMessage contains "deal" then set end of filteredMessages to contents of aMessage
    end repeat
end tell