searching mail by subject

Does anyone know of a way to search Mail for a message when you only have the subject? I have found references on the forum to finding by messageID but I don’t have that.


Model: MacBook Pro 17
AppleScript: XCode 2.4.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi deedeew

this may be of help

                            if whereToFind is equal to "Subject" then

                                if whatToFind is in the subject of m then

                                    copy m to end of messagesFound

                                end if


Thanks for the response. It appears that I am missing something in this. My requirements are quite a bit simpler than the example. I just want to search all the mailboxes for the first subject that matches the requirement.

repeat with theMailbox in mailboxes
		repeat with eachmessage in theMailbox
			if "hello today" is in the subject of eachmessage then
				set messID to id of eachmessage in theMailbox			end if
		end repeat
	end repeat
	open message messID
end tell

this does not result in finding and opening the message that I have placed in the inbox. Obviously, I haven’t done anything if the message is not found. I just wanted to see if it would find the message that I know is there.