Тело сообщения может быть определено использованием свойства 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