Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Go to next unread message in Mail via keyboard Apps
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.
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[16,653 views]  

Go to next unread message in Mail via keyboard | 14 comments | Create New Account
Click here to return to the 'Go to next unread message in Mail via keyboard' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Arrow Keys?
Authored by: rhowell on Jun 07, '04 01:15:06PM

If you have the preview pane open in Apple's Mail, with your list of Inbox messages on the top and the preview of the selected message on the bottom, then the up and down arrow keys will allow you to move the selection up and down the message list, subsequently showing you a preview of the newly selected message.



[ Reply to This | # ]
Arrow Keys?
Authored by: mephit on Jun 07, '04 01:50:47PM

While it is true you can use the preview pane and scroll through the message list with the arrow keys, there's still a snag. When you hit a message that's longer than the preview pane, you have to either mouse down or tab down to scroll through that message and then mouse back or tab back to move to the next message.

Personally, I like the way you can do it in Eudora. I have the open next message command set to CMND-Down arrow, then I just scroll through the window using the arrow keys. This means all navigation through the mail box can be done with just three keys (CMND, up arrow, down arrow). It would be nice if Mail allowed such a simple system. I just wish Eudora allowed the above to move you only to the next unread message, rather than just to the next in line.



[ Reply to This | # ]
Arrow Keys?
Authored by: DanFrakes on Jun 08, '04 12:22:22PM
While it is true you can use the preview pane and scroll through the message list with the arrow keys, there's still a snag. When you hit a message that's longer than the preview pane, you have to either mouse down or tab down to scroll through that message and then mouse back or tab back to move to the next message.

Just use the space bar -- space scrolls the previewed message down, shift-space scrolls up. Between the arrow keys and space bar, you can do all that you want.

[ Reply to This | # ]

Arrow Keys?
Authored by: osxpounder on Jun 08, '04 06:06:35PM

But only if you use the Preview Pane.

---
--
osxpounder



[ Reply to This | # ]
Go to next unread message in Mail via keyboard
Authored by: bluehz on Jun 07, '04 01:23:24PM

Is there a way to get Mail.app toactually open the next unread msg as opposed to just highlighting it as this script does? This is the same sort of action as Eudora. I tried adding:

open selected messages

as in

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
open selected messages
end tell

and it does work for the first initiation of the script (e.g. it opens the first unread msg), but each subsequent invocation of the script does nothing but highlight the next unread msg.



[ Reply to This | # ]
Go to next unread message in Mail via keyboard
Authored by: r.b on Jun 07, '04 01:31:41PM

i dont understand the "___ctl-n cause the script to use ^N as a keyboard shortcut."

does this work for all scripts in OSX? doesnt seem to work for me.



[ Reply to This | # ]
Go to next unread message in Mail via keyboard
Authored by: bluehz on Jun 07, '04 01:42:54PM

Yes - the shortcuts technique listed here works for any scripts (AS, shell, perl, etc) that you can use through the Scripts menu. Seems to be very little documentation on this though.



[ Reply to This | # ]
Go to next unread message in Mail via keyboard
Authored by: mike3k on Jun 07, '04 01:40:34PM

You can also simply hit spacebar to scroll through all messages. What I would really like is an option to jump to the next unread message in any mailbox when I reach the end of one mailbox like Mozilla does.



[ Reply to This | # ]
Go to next unread message in Mail via keyboard
Authored by: Cameroon on Jun 07, '04 11:42:09PM

Hitting the space bar only works with the preview pane open. And if you've got the preview pane open, you can use the arrow keys as well.

This script is for those of us who don't use the preview pane.



[ Reply to This | # ]
Doesn't appear to search threads...
Authored by: sharumpe on Jun 07, '04 02:19:22PM

I don't know much about Applescript, so this may be something easy that I'm missing. However, it doesn't appear that this searches messages that are arranged by thread. I can find all of the messages that are *not* in threads just fine.



[ Reply to This | # ]
Go to next unread message in Mail via keyboard
Authored by: kevjava1 on Jun 08, '04 11:20:05AM
I've got an answer to the guy who wanted Thunderbird mode... I just built on top of the poster's script here to make it check to find the first mailbox with unread messages, then find the first unread message in that box.

The only issue is, it only searches the messages in "On My Mac". The others, however, have Cmd-1 through Cmd-5 hotkeys already assigned to them, though, so this doesn't distress me much. I have a bunch of filters set up, and I have one that just dumps everything else into On My Mac->Inbox if it doesn't match anything else.


try
	tell application "Mail"
		activate
		
		-- Find the first 'other' mailbox that has unread messages.
		set unreadMailboxes to (the mailboxes whose unread count > 0) as list
		if (count of unreadMailboxes) is not 0 then
			set selected mailboxes of the front message viewer to 
				{the first item of unreadMailboxes}
		else
			beep
		end if
		
		tell the front message viewer
			-- Find the first unread message in the current mailbox.
			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



[ Reply to This | # ]
Go to next unread message in Mail via keyboard
Authored by: cran on Jun 12, '05 10:56:43AM

I use a smart folder called "Unread" that shows all my unread messages. In that folder I can use the spacebar to step through all my new e-mails.



[ Reply to This | # ]
Go to next unread message in Mail via keyboard
Authored by: JoelFarris on Oct 22, '05 10:05:36AM
[quote]I use a smart folder called "Unread" that shows all my unread messages. In that folder I can use the spacebar to step through all my new e-mails.[/quote] Ok, that may well be the best use of a smart mailbox I've ever heard of, and now I have to try it for myself! I'm having an specific issue within Mail regarding the "next unread message", and I wonder if anyone's got a suggestion for this problem. I'm subscribed to a email list, and I have setup a filter to move all incoming emails from that list into a folder for browsing. As I'm browsing the unread emails in that folder, which is sorted both as a 'date received' and 'threaded' view. I will read the first unread message, then hit the space bar to get to the next message. The posters on this list put their new comments at the top of the email, so reading 12 related postings is as simple as clicking to a message, reading the top paragraph withing the preview pane, and then clicking the next unreard message. I'd love to be able to navigate this via the keyboard like Thunderbird allows you to. Pressing 'N' to see the next unread message would be soo sweet. I wonder why Apple has not integrated a feature like this. Once a thread gets to about 10 or 12 postings, there is quite a bit of cruft left over at the bottom of each email. Pressing the space bar 8 times in order to scroll all the way through a message just to get to the next message is NOT GOOD for disabled users.

---
--
Joel Farris
"and that's the way it oughta be!"

[ Reply to This | # ]

Go to next unread message in Mail via keyboard
Authored by: boothefox on Oct 28, '05 05:59:26PM

In order to run the script you can use the free (at least for now) Butler http://www.petermaurer.de/nasi.php?thema=butler&sprache=english - you can make a hotkey or a script button on a menubar... life-saver ;)



[ Reply to This | # ]