Information from mail.app windows

I’m trying to get information such as message id from the open windows in mail.app. I can’t figure it out. Here’s an example of what I want to do…

I have 3 windows open in mail, 1) a message viewer with the inbox selected, 2) a todo item, and 3) an email message. I can get the 3 windows using the following. But when I get the properties of one of the windows it tells me nothing about the actual content of the window. I can’t tell if the window is displaying the message viewer or a message. There’s no distinguishing property such as “kind” of window or “message id” of the window.

tell application "Mail"
	set a to windows
	properties of (item 1 of a)
end tell

There is a name property and the name corresponds to the subject of a message… but this doesn’t help because many messages could have the same subject. Any ideas about how to learn what kind of window something is?

FYI: I found this old post asking the same kind of question from 2003. There was no resolution for it though.
http://macscripter.net/viewtopic.php?id=5516

Hi Hank,

there is a element message viewers in Mail.app. The open email message window is one of the selected messages.

Hope it helps

Hi StefanK. I really need to get the information right from each window. In my example I had 3 windows open and the selected item in the message viewer is only 1 of the open messages so it wouldn’t get me both open messages. What I eventually want to be able to do is save the current state of windows and then restore them at a future date. As such I need to get the bounds of each window (which is easy) and also get what each window is displaying so I can save that information.