work with Mail messages on Mavericks

Hello everyone.

I know various people on here have been battling with Mail and Mavericks, so I’d love to share my latest frustrations.

I’m trying to write a script that works with the contents of each account’s inbox. For regular IMAP accounts, the list of messages returned by AppleScript is updated when new messages are received, but those messages aren’t removed from the list until you restart Mail. For Gmail / Google Apps accounts, the list of messages returned for the inbox bears no resemblance to anything I’ve seen in there recently.

Here’s a simple script that gets the name of each account, then lists the subjects of the messages in its inbox.

tell application "Mail"
	repeat with i from 1 to count of accounts
		get name of account i
		get subject of messages of mailbox "INBOX" of account i
	end repeat
end tell

Does anyone else see a similar problem? And does anyone have any suggestions (other than “wait for Apple to fix it” :wink: ) for working around this problem?

Your routine did not work for me because in my mail app “INBOX” is in mixed case as “Inbox”. Then, it works fine.
:slight_smile:

Thanks for the reply! Yes, the case-senstivity is something that I came across as well. Are you saying that this is working fine for you in Mavericks? Are these with IMAP accounts? POP? Gmail via IMAP?

The Mail account that I used your code for, that did work perfectly after the capitalization issue, is an “Exchange” server. The docs at my university says its IMAP going in and SMTP going out. :rolleyes:

It really depends upon what you’re trying to do.

Gmail’s Inbox is frelled unless and until Apple decides to fix it, but you can play games with ‘All Mail’ if you want to.


-------------------------------------------------------------------------------------------

set nameSubjectList to {}
tell application "Mail"
	repeat with i in accounts
		tell (first item of (mailboxes of i whose name is "inbox"))
			set end of nameSubjectList to {get its account's name, get subject of messages}
		end tell
	end repeat
end tell

nameSubjectList

-------------------------------------------------------------------------------------------

set d to ((current date) - (24 * hours))
tell application "Mail"
	set mBox to first item of (get mailboxes of account "gmail" whose name contains "all mail")
	tell mBox
		subject of (messages whose date sent > d and read status = false)
	end tell
end tell

-------------------------------------------------------------------------------------------

Thanks for the reply, Chris. I’m hoping to avoid delving too far into the All Mail folder if Apple manage to fix this soon. :wink: