用于在 Entourage 中循环消息并删除它们的 AppleScript 代码

发布于 2024-09-18 22:44:50 字数 482 浏览 12 评论 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

现在,问题是,我想在获取主题后删除消息。我该怎么做?你能给我写一个例子吗?

再次感谢!

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

念﹏祤嫣 2024-09-25 22:44:50

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

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 的“方便”语法有时并非如此,这就是为什么我通常完全避免使用它。

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...

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's "convenience" syntax sometimes isn't, and that's why I usually avoid it altogether.

澉约 2024-09-25 22:44:50

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

repeat with theMsg in theMsgs
    delete theMsg -- puts in Deleted Items folder
    delete theMsg -- deletes completely
end repeat 

Here is a snippit from an example on Microsoft's Entourage help page (specifically the "Nuke Messages" script):

repeat with theMsg in theMsgs
    delete theMsg -- puts in Deleted Items folder
    delete theMsg -- deletes completely
end repeat 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文