2016-04-05 32 views
0

這工作:如何獲得消息的列表,從選擇在郵件中使用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 

出現錯誤「郵件出錯:無法將主題包含」deal「的所有選定郵件轉換爲類型說明符。」號碼-1700到說明者

我錯過了什麼?

回答

2

不幸的是,您不能在selection屬性上使用whose子句。

解決方法是重複循環

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 
相關問題