【问题标题】:AppleScript code for copying new email subject用于复制新电子邮件主题的 AppleScript 代码
【发布时间】:2020-06-26 17:43:36
【问题描述】:

我正在我的邮件应用程序中设置一个规则,以在来自特定发件人的电子邮件到达时执行下面的 AppleScript。我的目标是复制传入电子邮件的主题行,但是,此脚本复制主收件箱中当前选定电子邮件的主题,而不是传入电子邮件的主题。

有没有更好的方法来实现我的目标?

tell application "Mail"
    set _msgs to selected messages of message viewer 0
    if (_msgs is not equal to missing value) then
        set _msg to first item of _msgs
        set the clipboard to (subject of _msg) as string
    end if
end tell

【问题讨论】:

    标签: email copy applescript subject


    【解决方案1】:

    您需要使用 Mail 公开的内置处理程序来访问与规则激活关联的消息; selected messages of message viewer 0 只是访问活动的邮件窗口(如您所述)。相反,请使用 Mail 的 on perform mail action 处理程序来正确访问邮件。请参阅this question(和this answer)了解更多信息。

    这是您的代码,已重新编写以正确复制满足所提供规则条件的传入电子邮件的主题行。它在 macOS Catalina 10.15.5 上为我工作:

    using terms from application "Mail"
        on perform mail action with messages _msgs for rule _rule
            if (_msgs is not equal to missing value) then
                set _msg to first item of _msgs
                set the clipboard to (subject of _msg) as string
            end if
        end perform mail action with messages
    end using terms from
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-23
      • 2011-11-26
      • 1970-01-01
      相关资源
      最近更新 更多