规则的播放器#34;发送邮箱零"?

时间:2016-11-19 11:07:57

标签: email applescript

根据GTD和" inbox zero"我还想要一个相应的"发送邮箱零"在Apple Mail中应用规则。 (为什么?请看这个问题的结尾。)

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

工作流程就是这个

  1. 遍历所有已发送的消息,这些消息是对其他消息的回复。
  2. 获取已发送消息是回复消息的消息ID。
  3. 找到此(先前)消息的邮箱。
  4. 任何有关如何更有效地解决步骤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封电子邮件,而是将它们分类到基于上下文的邮箱中 - 发送邮件的邮箱为空!

    BTW,Pedro Lobo的Alfred工作流程邮件操作对于提交邮件简直太棒了。我的脚本sortOut完成其余的工作; - )

    抱歉,佩德罗,我没有足够的声誉来发布你杰出作品的链接。

1 个答案:

答案 0 :(得分:0)

我刚刚更新了代码,但仍无法使用Applescript(没有message:协议)从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