【问题标题】:How do I stop AppleScript from selecting all messages in a Mail.app conversation when I only want one from the group?当我只需要来自群组的一封邮件时,如何阻止 AppleScript 选择 Mail.app 对话中的所有邮件?
【发布时间】:2013-03-11 05:27:18
【问题描述】:

这是我的烦恼:我想将电子邮件添加到 Reminders.app 作为待办事项。我想通了那部分。我的下一个目标是能够选择多封电子邮件,并让 Reminders.app 为每个选定的电子邮件创建待办事项。我想通了。

问题:当我选择作为对话一部分的电子邮件时,来自该对话的所有 消息都被添加为单独的提醒/待办事项。这部分可能会令人困惑,但我会尽可能详细地描述我如何选择消息。在 Mail.app 中,我在最右侧窗格中选择了一条消息,其中所有属于对话部分的电子邮件都显示在可滚动列表中。这是我选择特定消息的区域。因此,即使我从对话中选择了一条消息,该对话中的所有消息都会添加到我的 AppleScript 列表变量中,并且随后会变成提醒/待办事项。

如果我在 Mail.app 中关闭“按对话组织”,问题就会消失。我喜欢通过对话组织我的电子邮件的整洁,所以如果有一个脚本解决这个问题,我更喜欢这条路线。但是,我想不出任何办法来解决这个问题,所以我希望这里的人有一些想法。

这是我的脚本:

property defaultList : "Parking Lot"

on newReminder(theBody, theTitle)
    tell application "Reminders"
        tell list defaultList
            make new reminder with properties {body:theBody, name:theTitle}
        end tell
    end tell
end newReminder


tell application "Mail"
    set selectedMessages to {}
    set selectedMessages to selection
    if (count of selectedMessages) is 0 then
        return "Please select a message in Mail.app and try again."
    else
        repeat with i from 1 to (count of selectedMessages)
            tell item i of selectedMessages
                set messageid to message id
                set urlText to "message://" & "%3c" & messageid & "%3e"
                set theSender to extract name from sender
                set theSubject to subject
                my newReminder((theSender & " " & urlText), theSubject)
            end tell
        end repeat
    end if
end tell

【问题讨论】:

    标签: applescript reminders


    【解决方案1】:

    Mail 应用程序的 AppleScript 属性 selection 似乎忽略了对话中的单个消息是否在预览窗格(OS X Lion 布局中最右侧的窗格)中突出显示。 selection 仅取决于在消息列表(中间窗格)中选择了哪些消息。如果您想在 AppleScript 中将selection 用于对话的单个消息,则必须从消息列表中选择单个消息,

    而不是预览窗格。

    【讨论】:

    • 我很尴尬地说我什至不知道以这种方式扩展消息列表的能力 - 现在看起来很明显。感谢您的帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-03-20
    • 2021-06-17
    • 1970-01-01
    • 1970-01-01
    • 2014-07-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多