Mail mailbox query, help required please...

Hi there,

I’ve trying to find the answer to this but as yet haven’t succeeded.

In my ‘Inbox’, in Mail, I have several subfolders. Please can someone tell me how I get the count of such a mailbox and how do I refer to a message within that subfolder.

I’ve tried this but the subfolder isn’t being found:-

tell application "Mail"
	set target_mailbox to "mailing list"
		set y to get mailbox target_mailbox
	end try
end tell

display dialog (count of y)

Thanks in advance,



This should get you started.

tell application "Mail"
	set EveryMailboxList to mailboxes
	set EveryMessageListInFirstMailbox to messages of item 1 of EveryMailboxList
	set TheSubject to subject of message 1 of item 1 of EveryMailboxList
	display dialog TheSubject
	--Get every Mailbox name
	set MialboxNameList to {}
	repeat with ThisMailBox in EveryMailboxList
		set MialboxNameList to MialboxNameList & (name of ThisMailBox as string)
	end repeat
	choose from list MialboxNameList
end tell

Have Fun

Thanks for the help and for the code.

I’m not sure why it is but when I execute the script I get an error with this line:-

set TheSubject to subject of message 1 of item 1 of EveryMailboxList

On looking at the values of ‘EveryMailboxList’ I only have 2 mailboxes listed, ‘Outbox’ and ‘Deleted Messages’, there’s no sign of ‘Inbox’?

This is the problem I was getting previously and I’m not sure if it’s something to do with the Inbox containing subfolders?

Any further help with this would be appreciated.



Finally got this to work:-

tell application "Mail"
	display dialog (count of messages of mailbox "THIS_MAILBOX" of account "THIS_ACCOUNT")
end tell