Well. I haven't managed to select the text, but at least I've figured out how to move the focus into the outgoing message body.
tell application "System Events"
if quit delay ≠ 0 then set quit delay to 0
tell application process "Mail"
tell front window
tell UI element 1 of scroll area 1
set focused to true
end tell
end tell
end tell
end tell
--------------------------------------------------------------
This solves my immediate problem which was to improve the reliability of a Keyboard Maestro macro.
I'd still like to know how to set the value of the message body using System Events if it's possible. (Directly - not with keystrokes.)
I know how to get the text if it exists, and that's quite useful for some other workflows.
--------------------------------------------------------------
tell application "System Events"
if quit delay ≠ 0 then set quit delay to 0
tell application process "Mail"
tell front window
tell UI element 1 of scroll area 1
set AppleScript's text item delimiters to linefeed
set messageBodyText to (value of static text of groups) as text
end tell
end tell
end tell
end tell
--------------------------------------------------------------
--
Best Regards,
Chris
--------------------------------------------------------------------------------------
Tags: @AppleScript, @System_Events, @System, @Events, @UI-Scripting, @Mail, @Outgoing,
: @Message, @Focused
--------------------------------------------------------------------------------------