Select every Message in a Mailbox. Apple Mail 5.2, OSX 10.7 Lion

Hey there,

I’ve got an Apple-Script, that selects every Message in a selected Mailbox. In 10.6 it works fine with this:



tell application "Mail"
	tell message viewer 1
		set selected messages to every message
	end tell
end tell


But in 10.7 I get an Error.

Can somebody help me?

Thank you very much!

Cheers
Marth

Ok,

This doesn’t do what you want, but its close?

tell application “Mail”
set theMessages to every message in the mailbox “INBOX” of account “XXXX”

repeat with theMessage in theMessages

    .... do something with each of "theMessage"

end repeat

end tell

Thank you very much Wizard2004,

Hmm…thats pretty cool! But, is there a way, that It works without the definition of the names of the Mailbox? Maybe the Script should give out the name of the selected Mailbox, is that even possible?

Thank you very much!!

Cheers
Marth


tell application "Mail"
	set theAccounts to every account
	set accountChoices to {}
	repeat with theAccount in theAccounts
		set the end of accountChoices to (name of theAccount as string)
	end repeat
	set theResult to (choose from list accountChoices with prompt "Choose one." without multiple selections allowed) as rich text
	set theAccount to the account theResult
	
	set theMessages to every message in the mailbox "INBOX" of theAccount
	repeat with theMessage in theMessages
		
		--do something with each of "theMessage"
		
	end repeat
end tell

Thank you very much!!!