【问题标题】:Applescript to rule "sent mailbox zero"?Applescript 规则“发送邮箱为零”?
【发布时间】:2016-11-19 11:07:56
【问题描述】:

根据GTD 和“inbox zero”,我还希望通过在 Apple Mail 中应用规则来获得相应的“发送邮箱零”。 (为什么?请看这个问题的结尾。)

现在,这是一个简单的 Applescript 解决方案:sortOut怎样才能更有效率?

工作流程就是这样

  1. 遍历所有已发送的作为对其他消息的回复的消息。
  2. 获取已发送消息作为回复的消息的消息 ID。
  3. 找到此(先前)邮件的邮箱。

任何如何更有效地解决步骤 3 的建议将不胜感激,例如直接根据消息 id 定位邮箱,无需使用message: 协议然后打开消息,最好不要编写类似... (in every mailbox) whose message id is mID 的代码,这样会很慢。

tell application "Mail"
    set i to 0
    set mb1 to sent mailbox
    repeat with m in ((messages of mb1) whose all headers contains "In-Reply-To")
        set mID to content of header "In-Reply-To" of m
        set cmd to "open 'message:" & mID & "'"
        try
            do shell script cmd
            delay 1
            set s to the selection
            set m2 to item 1 of s
            set mb2 to mailbox of m2
            set mailbox of m to mb2
            close front window
            set i to i + 1
        end try
    end repeat

    if i ≠ 1 then
        set s to "s"
    else
        set s to ""
    end if

    set myMsg to (i & " message" & s & " moved successfully") as rich text
    display notification myMsg with title "SortOut" subtitle "Sorting complete"
end tell

其他地方的一些早期讨论表明,有些人甚至可能想知道我为什么想要这个。我的理由很简单,我喜欢根据上下文收集所有关于每个项目和截止日期的线程和对话。

当一个项目完成后,我会将其存档为一个已完成的实体,以便在我需要返回或跟进某些事情时方便参考(例如,在计划年度活动时,“记住我去年回答过这个问题?”这也意味着所有这些对话都将在 gmail 中具有相同的标签。

因此,我现在将它们分类到基于上下文的邮箱中,而不是在一个邮箱中发送近 15000 封电子邮件 - 已发送邮件的邮箱是空的!

顺便说一句,Pedro Lobo 的 Alfred 工作流程 Mail Actions 非常适合归档邮件。我的脚本sortOut 完成了剩下的工作;-)

抱歉,佩德罗,我没有足够的声誉来发布指向您出色作品的链接。

【问题讨论】:

  • 我刚刚更新了代码,但问题仍然存在:怎样才能更有效率?

标签: email applescript


【解决方案1】:

我刚刚更新了代码,但仍然无法使用 Applescript(没有 message:protocol)从 In-Reply-To 标头中找到与消息 ID 对应的邮箱。

tell application "Mail"
    set i to 0
    set mb1 to sent mailbox
    repeat with m in ((messages of mb1) whose all headers contains "In-Reply-To")
        set mID to content of header "In-Reply-To" of m
        set cmd to "open 'message:" & mID & "'"
        try
            do shell script cmd
            delay 1
            set s to the selection
            set m2 to last item of s
            set mb2 to mailbox of m2
            if name of mb2 does not contain "INBOX" then
                set mailbox of m to mb2
                close front window
                set i to i + 1
            end if
        end try
    end repeat

    if i ≠ 1 then
        set s to "s"
    else
        set s to ""
    end if

    set myMsg to (i & " message" & s & " moved successfully") as rich text
    display notification myMsg with title "SortOut" subtitle "Sorting complete"
    mb2
end tell

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-30
    • 2018-06-26
    • 2019-10-26
    • 1970-01-01
    • 2022-12-30
    • 2018-08-13
    • 1970-01-01
    相关资源
    最近更新 更多