Automators 2: Email Automation

episode

#41

Oh well, turns out it was not “simple enough” - at least for me.

When I modified the script to read as below, I don’t get first name greetings. Instead, the applescript itself is pasted into the mail message.

    tell application "System Events"
	tell process "Mail"
		tell text field "To:" of window 1
			get count of UI elements
			if result is 1 then
				set theToRecipient to (value of UI element 1)
				return word 1 of theToRecipient
			else if result is 2 then
				set the1stToRecipient to (value of UI element 1)
				set the2ndToRecipient to (value of UI element 2)
				return word 1 of the1stToRecipient & " and " & word 1 of the2ndToRecipient
			else if result is 3 then
				set the1stToRecipient to (value of UI element 1)
				set the2ndToRecipient to (value of UI element 2)
				set the3rdToRecipient to (value of UI element 3)
				return word 1 of the1stToRecipient & ", " & word 1 of the2ndToRecipient & " and " & word 1 of the3rdToRecipient
			else if result is greater than 3 then
				return "all"
			end if
		end tell
	end tell
end tell

#42

If you are using TextExpander, make sure you have the snippet format set as AppleScript.


#43

oh duh!

(Now it works.)

Thanks!