【问题标题】:Mavericks Mail Applescript Changes小牛队邮件 Applescript 更改
【发布时间】:2013-11-18 16:36:03
【问题描述】:

到目前为止,Mavericks 的表现相当不错,但我使用多年的一个值得信赖的 Applescript 发现它不再工作了。脚本在这里:

tell application "Mail"
    set the clipboard to (content of first message of ¬
        inbox whose subject contains "2013-11-05") as string
end tell

脚本的工作是从主题为“J-List Reports 2013-11-05”的电子邮件中获取内容(显然每天都会发生变化)。如果我将脚本更改为查找没有日期的“J-List 报告”,它可以正常工作,但它会收到错误的电子邮件,因为我无法指定日期(它会查找恰好在主题)。如果 Applescript 中有任何数字,试图强制它找到正确的电子邮件,我会得到 ​​p>

“邮件出错:无法收到主题为收件箱的邮件 1 包含 2013-11-05"

即使没有其他任何改变。

谁能建议一种方法来指定正确的邮件,也许是任何主题包含“J-List 报告”且月份为 11 且日期为 5 的邮件?我花了几个小时,但无法让它为我工作。

【问题讨论】:

    标签: email applescript osx-mavericks


    【解决方案1】:

    这对我有用:

    tell application "Mail"
        content of message 1 of mailbox "[Gmail]/All Mail" of account "Gmail" where subject contains "2013-11-05"
    end tell
    set the clipboard to result
    

    消息从最新到最旧排序,因此message 1 应该是最新消息。

    tell application "Mail" to messages of inboxtell application "Mail" to messages of mailbox "INBOX" of account "Gmail" 由于某种原因返回了一个空列表。

    【讨论】:

    • 嗨劳里。我对空列表也有同样的问题。这也不起作用:告诉应用程序“邮件”发送邮箱的消息
    【解决方案2】:

    这对我来说很好用

    tell application "Mail"
        try
            set the clipboard to (content of first message of ¬
                inbox whose subject contains "2013-11-05") as string
        on error errMsg
            display dialog "an error: " & errMsg
        end try
    end tell
    

    尝试将字符串更改为您知道存在的字符串,当我搜索没有匹配项的电子邮件时,我得到了同样的错误。我怀疑您也没有在此处包含完整的错误消息

    rror "Mail got an error: Can’t get message 1 of inbox whose subject contains \"2013-11-05\". Invalid index." number -1719
    

    无效索引对诊断很重要,因为它可以准确地告诉我们问题所在。主题包含2013-11-05的地方没有可以识别的消息

    所以你应该使用 try 语句,然后决定从那里做什么。

    邮件版本 7.0 (1816) 操作系统 10.9 构建 13a603

    【讨论】:

      猜你喜欢
      • 2014-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-02
      • 2013-11-01
      • 2014-10-30
      相关资源
      最近更新 更多