Change Sender of open Mail message

I am the newbiest of newbies and cannot find an answer to the following question. I would be most grateful for assistance:

I want to use Applescript to change the Sender of an existing unsent open message to any one of the accounts I use. The message was created with Filemaker but I cannot set the Sender in Filemaker (it uses the Mail default set in Preferences). Although I can easily set the Sender (via Properties) of a new message created in Applescript, I can’t seem to change the Sender of an existing message.

It would be equally OK to use Applescript to change the Compose Preference temporarily and change it back after the mail has been sent.

I think I am doing something wrong in trying to access the Properties of the existing message.

Thank you again.


Hi Stuart,

I recommend to pass the data to and compose the message in, which is probably more convenient

I have the exact same problem:

Go to mail, hit cmd+N to create a new message and a new window to compose a message appears. I have several addresses configured and I want to switch between my 3 most-used addresses using a keyboard shortcut. This means I need a script that can switch the “From:” field to another value in an ALREADY EXISTING (outgoing) message.

How do I get access to the message I’m composing using applescript when I initially did not create the message in applescript?

Once I have access to the message, how do I change the value of the “From:” field to the next value or to some arbitrary value from the drop-down when changing the value in the GUI?


I googled around and as usual StackOverflow had the answer

Here is my GUI scripting solution, because you cannot access an outgoing message programmatically after it has been created:

tell application "System Events"
	tell process "Mail"
		tell window 1
			click pop up button 1
			tell pop up button 1
				repeat with counter from 1 to <insertTotalNumberOfSenderAddresses>
					if (selected of menu item counter of menu 1) then
						if name of menu item counter of menu 1 contains "<insertCriterium>" then
							click menu item 1 of menu 1
							click menu item 10 of menu 1
						end if
						exit repeat
					end if
				end repeat
			end tell
		end tell
	end tell
end tell