Go to next unread message in Mail via keyboard

Jun 07, '04 10:51:00AM

Contributed by: landers

I have finally figured out how to step to the next unread message in mail.app. This has probably been my number one gripe with mail since I switched to Mac OS X. Here's the script:

try
  tell application "Mail"
    activate
    tell the front message viewer
      set unreadMessages to (the messages whose ¬
       read status is false) as list
      if (count of unreadMessages) is not 0 then
        set selected messages to {the first item of unreadMessages}
      else
        beep
      end if
    end tell
  end tell
  on error error_message
  beep
  display dialog "Error looking for next unread message: " & ¬
   return & return & error_message buttons {"OK"} default button 1
end try
Using Script Editor, save it as something like NextUnreadMessage___ctl-n.scpt in your Mail Scripts folder. The three underscores plus ctl-n cause the script to use ^N as a keyboard shortcut.

Comments (14)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040603184913904