Automators 2: Email Automation

After several hours, I was able to get it to work for the latest version of Outlook for Mac using this code to replace David’s xnm script:

tell application "System Events"
	tell process "Outlook"
		tell text area 1 of scroll area 1 of splitter group 1 of window 1
			get count of buttons
			if result is 1 then
				set theToRecipient to (value of button 1)
				return word 1 of theToRecipient
			else if result is 2 then
				set the1stToRecipient to (value of button 1)
				set the2ndToRecipient to (value of button 2)
				return word 1 of the1stToRecipient & "/" & word 1 of the2ndToRecipient
			else if result is greater than 2 then
				return "all"
			end if
		end tell
	end tell
end tell

I also pulled in @Rockitude’s idea of seeing if there’s more than one person in the To: box. If there are two people it inserts FirstName1/FirstName2.

In the end, it works pretty great!

1 Like