2009-02-20 35 views
2

我寫了一個簡短的Applescript將選定的郵件移動到該郵箱的相關存檔。但是,當它運行時不再有選擇。 (如果我按上或下,它會選擇整個郵箱中的第一封或最後一封郵件)。我無法解決如何使用AppleScript選擇當前選擇之外的下一條消息。只要接近選擇(即將消失),我並不介意「next」是前後的消息。如何在使用Applescript的郵件中選擇外部的下一條消息?

如果有幫助,這是我的AppleScript:

tell application "Mail" 
    set selectedMessages to selection 
    repeat with theMessage in selectedMessages 
     set theAccount to account of mailbox of theMessage 
     set read status of theMessage to true 
     set mailbox of theMessage to mailbox "_old" of theAccount 
    end repeat 
end tell 

回答

2

嘗試是這樣的:

tell application "Mail" 
    set theSelection to selection 
    set theMessage to item 1 of theSelection 
    set theMailbox to theMessage's mailbox 
    set theMessageID to theMessage's id 
    set theMessageIDs to (id of every message of theMailbox) 
    -- do work here 
    set theMessages to (every message of theMailbox) 
    repeat with i from 1 to (count theMessageIDs) 
     if item i of theMessageIDs is theMessageID then 
      set message viewer 1's selected messages to {item i of theMessages} 
      exit repeat 
     end if 
    end repeat 
end tell 

注意,這個假設的幾件事情,只有一個郵箱被選中,你不移動最後的消息,等等。

相關問題