代码之家  ›  专栏  ›  技术社区  ›  Singletoned

如何使用AppleScript选择邮件中选定内容之外的下一封邮件?

  •  2
  • Singletoned  · 技术社区  · 16 年前

    我编写了一个简短的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
    
    1 回复  |  直到 16 年前
        1
  •  2
  •   Nicholas Riley    16 年前

    尝试如下操作:

    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
    

    请注意,这假设有一些事情只有一个邮箱被选中,您没有移动最后一条消息,以此类推。