This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application “System Events” | |
tell process “Mail” | |
tell text field “To:” of window 1 | |
if UI element 1 exists then | |
set theToRecipient to (value of UI element 1) | |
if (get text of theToRecipient) contains “,” then return word 2 of theToRecipient | |
if (count words of theToRecipient) is greater than 0 then return word 1 of theToRecipient | |
end if | |
end tell | |
end tell |