【问题标题】:Using AppleScript to reply to selected message in Mail使用 AppleScript 回复邮件中的选定邮件
【发布时间】:2015-08-02 15:18:18
【问题描述】:

第一次海报和 AppleScript 新手。

我正在尝试制作一个 AppleScript,它在 mail.app 中接收选定的邮件并打开一个回复窗口。简而言之,我希望它的功能与在 mail.app GUI 中按下“回复”按钮完全一样:打开回复窗口并自动填写收件人、主题和正文字段。

我得到的最接近的是:

tell application "Mail"

    set theSelection to selection
    if theSelection is {} then return
    activate

    repeat with thisMessage in theSelection
        set theOutgoingMessage to reply thisMessage with opening window
    end repeat

end tell

不幸的是,这会为所选对话中的每条消息创建一个新的回复窗口。例如:如果我运行此脚本时对话中有 4 条消息,我会得到 4 个单独的回复窗口。

即使我在对话中只选择了一条消息(例如,最顶部的消息),脚本仍然会打开 4 个单独的回复窗口。

我也尝试了以下方法,但没有任何反应:

tell application "Mail"

    set theSelection to item 1 of selection
    if theSelection is {} then return
    activate

    set theOutgoingMessage to reply theSelection with opening window

end tell

但这没有可见的结果(根本没有打开窗口)。有什么帮助可以为我指明正确的方向吗?

.R

【问题讨论】:

  • 我现在不在 Mac 上。但我怀疑您为邮件设置了线程视图。如果是这样,当您选择 1 封电子邮件时,您实际上是在选择线程中的所有电子邮件尝试将视图更改为非线程。
  • 终于让它工作了

标签: macos email applescript


【解决方案1】:

以下代码最终对我有用:

tell application "Mail"
    set theMessages to the selected messages of the front message viewer
    set theMessage to first item of theMessages
    set theOutgoingMessage to reply theMessage with opening window and reply to all
end tell

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-03
    相关资源
    最近更新 更多