3

Is there a way to show the exact number of unread mails from the Mail.app icon also in the title bar? Note that this is not the same as showing the number of unread mails in inbox, since I can change the folder to something else like a smart mailbox.

(A script which outputs this number would also be okay; I could write a menu bar item around this myself.)

Update: Alternatively, a script which outputs the number of unread mails for a user-definable smart mailbox is also okay. All example code I’ve seen so far only works for non-smart mailboxes.

2

You can obtain the number of unread items with the following AppleScript:

tell application "Mail" to get the count of messages of mailbox "INBOX" of account "Me"

As you mentioned you could write a menu bar item, you could use this AppleScript for it.

Alternatively, you can do this with Mail Unread Menu.
However, I'm not sure if it works with Mavericks.

  • 1
    Your script shows the number of messages in inbox not from the folder specified in Mail.app settings. – Debilski Jun 15 '14 at 13:36
  • @Debilski Yes, but the script can be modified—change mailbox "INBOX" to whatever you desire. – grg Jun 15 '14 at 13:37
  • 1
    Does not work for smart mailboxes or at least I did not have any luck with it. – Debilski Jun 15 '14 at 13:39
0

Try this:

set unreadNumber to 0
set i to 1
tell application "Mail"
activate
get message viewer 1's selected mailboxes
repeat with thisBox in result
    repeat until ((message number is i) exists) is false
        if read status of (message number i of thisBox) is true then set unreadNumber to (unreadNumber + 1)
        set i to i + 1
    end repeat
end repeat
display dialog "You have " & unreadNumber & " unread messages."
end tell
  • Not 100% sure what this does but it looks as if it takes quite some time for more than just a few messages. Also, it seems to return the total number of unread messages (?) which is not what I need. – Debilski Jun 18 '14 at 11:19
  • To quote you: "a script which outputs the number of unread mails for a user-definable smart mailbox is also okay." Perhaps you need to make your question clearer. – man-qa Jun 18 '14 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .