Skip to content

Instantly share code, notes, and snippets.

@fortybillion
Created February 17, 2010 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fortybillion/306931 to your computer and use it in GitHub Desktop.
Save fortybillion/306931 to your computer and use it in GitHub Desktop.
Mail.app "Next Unread Message"
tell application "Mail" to try
set mailAccounts to every account
set messageFound to false
repeat with acc in mailAccounts
if not messageFound then
try
set unreadMessage to {last message of mailbox "INBOX" of acc whose read status is false}
set messageFound to true
set accountWithUnread to acc
end try
end if
end repeat
if accountWithUnread exists then
tell message viewer 1
set selected mailboxes to {first mailbox of accountWithUnread whose name is "INBOX"}
delay 0.1
set selected messages to unreadMessage
end tell
end if
activate
on error
beep
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment