how to get recipients of current new message?

Hi,

This is probably very easy, but I cannot figure out how to do it.

I double click on Mail and select File: New Message.
I enter an e-mail address, say allan@lanl.gov

I would now like to run a script that simple displays the recipients of this new e-mail message in a dialog (I actually want to do more, but I can handle the rest).

I just cannot figure out how to get the recipients from this open new e-mail message.

Your help is greatly appreciated.

-Allan

Hi Allen,

This is not as simple as you might suppose. The New Message window is not very scriptable
at all. You can create a New Message and script all the parameters but once it is open getting
information in or out is not easy.

As long as the email address is an actual email like “allan@lanl.gov” then the following script
will work. If the email turns to the blue circle with only the recipient’s name then it will not work.

activate application "Mail"
tell application "System Events"
	tell process "Mail"
		set msg_recipient to get value of text field 1 of scroll area 2 of window "New Message"
	end tell
end tell

To get this information I used the program UIBrowser. It comes in very handy when doing GUI
scripting.

Regards,

Craig

Faster replies using “Latest MacScripter Posts” :wink:
http://scriptbuilders.net/files/latestmacscripterposts1.0.html

thanks, but this script didn’t work for me. I just get an empty string. :frowning:

Hi,

in my Mail.app (3.2) it’s scroll area 3.
This gathers also the menu buttons


activate application "Mail"
tell application "System Events"
	tell process "Mail"
		tell text field 1 of scroll area 3 of window "New Message"
			set msg_recipient to get title of menu buttons
			set end of msg_recipient to value
		end tell
	end tell
end tell