2

我写了一个简短的 Applescript 将选定的邮件移动到该邮箱的相关存档中。但是,当它运行时,不再有选择。(如果我然后按向上或向下,它会选择整个邮箱中的第一条或最后一条消息)。我不知道如何使用 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
4

1 回答 1

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

请注意,这假设了一些事情——只选择了一个邮箱,您没有移动最后一封邮件,等等。

于 2009-04-05T18:44:49.043 回答