The body of the message can determine my use of the property of the contentmessage that was passed to the rule. To execute the script, use the command run script.
The following script example is an example of writing AppleScript that can be attached as an action of a rule that will process the message body as 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
sakra source
share