当我收到一封带有“AppleScript”主题的电子邮件时,我设置了Mail来执行AppleScript,我想知道如何将此电子邮件的正文传递给脚本执行。
提前致谢!
答案 0 :(得分:5)
消息正文可以确定我使用已传递给规则操作的消息的content
属性。要执行脚本,请使用run script
命令。
以下脚本是一个如何编写AppleScript的示例,该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