【问题标题】:How to get Mail.app raw message in the Automator?如何在 Automator 中获取 Mail.app 原始消息?
【发布时间】:2013-07-31 21:49:28
【问题描述】:

需要从 OS X Mail.app 获取原始邮件内容并将其传递给下一个操作。

不幸的是 - 测试了这个 - 并且不起作用::(

我不想选择消息的“内容”,但想将raw 内容(base64 编码的内容)传递给下一个操作。

因此,在“获取选定的邮件”和“新文档”之间可能需要一些 applescript action

不知道怎么做...

“New TextEdit doc”仅用于测试,实际操作将是一个perl 脚本,将从stdin 读取raw message content

【问题讨论】:

  • 不知道能不能用applescript获取原始内容。您应该首先查看 Mail 的 applescript 字典以找到用于该命令的命令……如果存在的话。只需转到 AppleScript 编辑器的文件菜单,选择“打开字典”,选择邮件应用程序并开始查找。如果您找到命令,请告诉我们,我们可以帮助您将一些东西放在一起。

标签: macos applescript automator


【解决方案1】:

试试:

on run {input, parameters}
    set theSource to {}
    tell application "Mail"
        repeat with aMessage in input
            set end of theSource to aMessage's source & return
        end repeat
    end tell

    return theSource as text
end run

【讨论】:

    【解决方案2】:

    这是在“获取选定的邮件”操作之后运行的 AppleScript 操作的一些代码。它被放置在一个动作中:“运行 AppleScript”

    -- This script accepts an input which is a list of message objects from Mail and returns their properties.
    -- The properties returned are in the form of an AppleScript properties record.
    on run {input, parameters}
        tell application "Mail"
            set output to {}
            repeat with thisMessage in input
                set output to output & (properties of thisMessage)
            end repeat
        end tell
        return output
    end run
    

    我认为这个脚本是进步的,但它的动作会返回一个 AppleScript 记录列表。您可能希望在 AppleScript 中选择您想要的字段,并将所有邮件消息作为文本返回以供下一个操作,您的 Perl 脚本能够解析纯文本,而不必处理 AppleScript 记录。

    您可以使用上面的 AppleScript 来查看记录键和值,然后编写一个 AppleScript 以实际用于您完成的工作流程,该工作流程只选择您想要的字段。

    -- 凯德尔
    kaydell@yahoo.com
    http://learnbymac.com

    【讨论】:

    • 可能,您想将重复循环中的行替换为:将输出设置为输出 & thisMessage 的来源 & 返回
    猜你喜欢
    • 2018-07-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-13
    • 2014-09-17
    • 2021-10-31
    • 2015-10-05
    相关资源
    最近更新 更多