我写了一个简单的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现在,问题是,我想在获得主题后删除邮件。我该怎么做呢?你能给我写个例子吗?
再次感谢!
发布于 2010-09-16 22:52:58
一旦您删除了一条消息,您就更改了消息列表的长度,因此在某些时候,您将遇到一个不再存在的索引,因为您已经删除了足够多的消息。要解决此问题,您必须(本质上)对循环进行硬编码;获取消息计数,并从最后一条消息开始向上移动。即使您删除了一封邮件,当前邮件上方的索引也将始终保持不变。未经测试,但这是我在其他地方使用过的模式。
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 repeatApplescript的“方便”语法有时并非如此,这就是我通常完全避免使用它的原因。
发布于 2010-09-15 23:32:47
以下是Microsoft的Entourage帮助页面上的一个示例(特别是"Nuke Messages“脚本)中的一段代码:
repeat with theMsg in theMsgs
delete theMsg -- puts in Deleted Items folder
delete theMsg -- deletes completely
end repeat https://stackoverflow.com/questions/3719085
复制相似问题