0

我写了一个简单的 AppleScript,它在 Entourage Inbox 中无限循环并获取“未读”消息的主题:

tell application "Microsoft Entourage"
activate

repeat with eachMsg in messages of folder named "Inbox"
    if read status of eachMsg is untouched then
        set messageSubject to subject of eachMsg as string

        -- bla bla bla

        -- How to delete the message and proceed with the next one???
    end if

end repeat

现在,问题是,我想在获得主题后删除消息。我怎样才能做到这一点?你能给我写一个例子吗?

再次感谢!

4

2 回答 2

0

以下是 Microsoft 的 Entourage 帮助页面(特别是“Nuke Messages”脚本)上的示例片段:

repeat with theMsg in theMsgs
    delete theMsg -- puts in Deleted Items folder
    delete theMsg -- deletes completely
end repeat 
于 2010-09-15T15:32:46.833 回答
0

一旦你删除了一条消息,你就改变了消息列表的长度,所以在某些时候,你会遇到一个不再存在的索引,因为你已经删除了足够多的消息。为了解决这个问题,您必须(基本上)对循环进行硬编码;获取消息的数量,并从最后一条消息开始并从那里向上移动。即使您删除了一条消息,当前消息上方的索引也将始终保持不变。未经测试,但这是我在其他地方使用过的模式......

tell application "Microsoft Entourage"
activate
set lastMessage to count messages of folder named "Inbox"
repeat with eachMsg from lastMessage to 1 by -1
    set theMsg to message eachMsg of folder named "Inbox"
    if read status of theMsg is untouched then
        set messageSubject to subject of theMsg as string

        -- bla bla bla

        -- How to delete the message and proceed with the next one???
    end if

end repeat

Applescript 的“方便”语法有时不是,这就是我通常完全避免它的原因。

于 2010-09-16T14:52:57.727 回答