将电子邮件正文传递给 AppleScript

发布于 2024-09-01 11:19:46 字数 96 浏览 2 评论 0原文

我将 Mail 设置为在收到主题为“AppleScript”的电子邮件时执行 AppleScript,我想知道如何将此电子邮件的正文传递给脚本来执行。

提前致谢!

I have Mail set up to execute an AppleScript when it receives an email with the subject "AppleScript" and I was wondering how I could pass the body of this email to the script for execution.

Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撕心裂肺的伤痛 2024-09-08 11:19:46

消息正文可以使用已传递给规则操作的消息的 content 属性来确定。要执行脚本,请使用run script 命令。

以下脚本是如何编写可作为规则操作附加的 AppleScript 的示例,该规则操作会将消息正文作为 AppleScript 运行:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with theMessage in theMessages
                set theBody to content of theMessage as text
                my executeScript(theBody)
            end repeat
        end tell
    end perform mail action with messages
end using terms from

on executeScript(theScript)
    display alert "Run the following AppleScript?" message theScript buttons {"Cancel", "Run"}
    if button returned of result = "Run" then
        run script theScript
    end if
end executeScript

The body of a message can determined my using the content property of the message that has been passed to the rule action. To execute the script use the run script command.

The following script is an example of how to write an AppleScript that can be attached as a rule action that will run the body of the message as an AppleScript:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with theMessage in theMessages
                set theBody to content of theMessage as text
                my executeScript(theBody)
            end repeat
        end tell
    end perform mail action with messages
end using terms from

on executeScript(theScript)
    display alert "Run the following AppleScript?" message theScript buttons {"Cancel", "Run"}
    if button returned of result = "Run" then
        run script theScript
    end if
end executeScript
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文