searching subject line in mail.app

what i am trying to do is search my mailboxes for a specific subject line.

i seem to be having a problem with the "if subject… " line in the repeat loop.

set theMailbox to mailboxes

repeat with eachMessage in theMailbox
	if subject of eachMessage is "Hello" then
		set myAddress to sender of eachMessage
	end if
end repeat

any ideas???

using OSX.2.4 and mail.app

When you ‘set theMailbox to mailboxes’, ‘theMailbox’ contains a list of mailboxes. Your script is looking for messages. You need one repeat loop that works through the mailboxes and another to work through the messages of each mailbox.