Opening Mail.app messages

After extensive searching of past threads and documentation I am stumped with how to open a message nicely in Mail.app. Normally I leave the mail running with the main window closed and so I’d like to be able to manage the mail without using that window. I can already compase messages and check for mail via the dock menu, I just need to be able to open new messages. what I have so far:


(*
	Display unread messages
*)

tell application "Mail"
	if unread count of in mailbox > 0 then
		repeat with mesg in (get messages of in mailbox)
			if not is read of mesg then
				-- presto!! open mesg ??
			end if
		end repeat
	end if
end tell

this correctly detects the presence of new messages and will do an action upon finding an unread message, but I can’t figure out that missing line. The effect I would like is as if I double clicked the message in the main window and it brings up the message in its own window.

This was recently discussed on the applescript-users mailing list and it appears that it is practically impossible to open a message via AppleScript.

Note: If you follow the link above, you may be required to enter a user name and password. Use ‘archives’ for both.

– Rob

however… While looking at one of apple’s examples (Developer:Examples:ApplescriptStudio:Mail Search) in the file “Mail Search.applescript” there is a function, makeMessageWindow(). This function loads a nib for a message included in its own bundle (I think…) and then fills in its information. No the scripting part is a little over my head but would it be possible to load the nib of a recieved message and then fill in its appropriate bits (from the message that was found in the last code tidbit) and then set is read of mesg to true? (PS for convienence here’s the function:)


on makeMessageWindow()
	load nib "Message"
	set windowCount to windowCount + 1
	set windowName to "message " & windowCount
	set name of window "message" to windowName
	return window windowName
end makeMessageWindow

I believe the appropriate nib file is Applications:Mail.app:Resources:English.lproj:MessageWindow.nib (from Mail.app)

does that help? I am still new to applescript so I don’t know the boundries or how to implement what I believe to be the answer, but I can code…

It doesn’t help me since I use Eudora. Maybe someone else who knows more about Mail and nib files can pick up the ball and run with it. :slight_smile:

– Rob