Monday, July 16, 2018

#1 2006-07-15 06:53:58 am

Bruce Phillips
Administrator
Registered: 2004-07-16
Posts: 2649

Mail.app: Next Unread Message

(Using Mail.app v2.*)

Applescript:

tell application "Mail"
   activate
   
   set messageList to {}
   get message viewer 1's selected mailboxes
   repeat with thisBox in result
       set messageList to messageList & (messages of thisBox whose read status is false)
   end repeat
   
   try
       set message viewer 1's selected messages to {(messageList's last item)}
   on error
       beep
   end try
end tell

You may want/need to change `last item` to `first item` (depending on how you view and sort your messages).

Model: Mac mini
AppleScript: 1.10.7
Browser: Safari 2.0.4 (419.3)
Operating System: Mac OS X (10.4)


Filed under: mail

Offline

 

#2 2006-07-15 09:28:17 am

Qwerty Denzel
Member
Registered: 2005-06-11
Posts: 337

Re: Mail.app: Next Unread Message

Nice. In the following I've simplified it without the repeat loop:

Applescript:

tell application "Mail" to try
   tell message viewer 1 to set selected messages to {first message of beginning of (get selected mailboxes) whose read status is false}
   activate
on error
   beep
end try


Filed under: mail

Offline

 

#3 2006-07-15 10:03:57 am

Bruce Phillips
Administrator
Registered: 2004-07-16
Posts: 2649

Re: Mail.app: Next Unread Message

Qwerty Denzel wrote:

Nice. In the following I've simplified it without the repeat loop:


Even better Qwerty. cool

I had been using the repeat loop for something else before I went with the above. (I'm not familiar with Mail's dictionary.)

Offline

 

#4 2009-05-21 02:44:13 pm

Lecter
Member
Registered: 2009-01-28
Posts: 1

Re: Mail.app: Next Unread Message

I realize that this is a very old post. On the chance anyone is still watching this, I have a question.

On 10.5.7, in Mail 3.6, I noticed that this script does not move from mailbox to mailbox (it does seem to select the first unread message in the selected mailbox).

Any one have any idea on how to update the script to select the next unread message, regardless of which mailbox it is in?

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)