我写了一个简单的苹果本,该苹果本无限期地在随行人员收件箱中循环,并获得了“未读”消息的主题:

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

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

再次感谢!

有帮助吗?

解决方案

删除消息后,您将更改了消息列表的长度,因此在某个时候,您将遇到一个索引,因为您已经删除了足够的消息,因此不再存在。为了解决这个问题,您必须(本质上)(本质上)硬码循环;获取消息的计数,然后从上一条消息开始,然后从那里向上移动。即使您删除了一条消息,当前索引上方的索引始终是完整的。未经测试,但是我在其他地方使用的模式...

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的“便利性”语法有时不是,这就是为什么我通常完全避免它的原因。

其他提示

这是Microsoft随行帮助页面上一个示例中的snippit(特别是“核武器消息”脚本):

repeat with theMsg in theMsgs
    delete theMsg -- puts in Deleted Items folder
    delete theMsg -- deletes completely
end repeat 
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top