用于在 Entourage 中循环消息并删除它们的 AppleScript 代码
我编写了一个简单的 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
现在,问题是,我想在获取主题后删除消息。我该怎么做?你能给我写一个例子吗?
再次感谢!
I wrote a simple AppleScript which loops indefinitely inside Entourage Inbox and gets subjects of "unread" messages:
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
Now, the problem is, I want to delete messages after getting the subject. How can I do this? Could you please write me an example?
Thanks again!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一旦你删除了一条消息,你就改变了消息列表的长度,所以在某些时候,你会遇到一个不再存在的索引,因为你已经删除了足够多的消息。为了解决这个问题,您必须(本质上)对循环进行硬编码;获取消息数,并从最后一条消息开始并从那里向上移动。即使您删除了一条消息,当前消息之上的索引也将始终保持不变。未经测试,但这是我在其他地方使用过的模式...
Applescript 的“方便”语法有时并非如此,这就是为什么我通常完全避免使用它。
Once you delete a message, you have changed the length of the message list, so at some point, you are going to come across an index that no longer exists because you have deleted enough messages. To get around this, you have to (essentially) hard code the loop; get the count of messages, and start from the last message and move up from there. Even though you have deleted a message, the indexes above the current one will always be intact. Untested but is a pattern I've used elsewhere...
Applescript's "convenience" syntax sometimes isn't, and that's why I usually avoid it altogether.
以下是 Microsoft Entourage 帮助页面上示例的片段(特别是“Nuke Messages”脚本):
Here is a snippit from an example on Microsoft's Entourage help page (specifically the "Nuke Messages" script):