• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get unread message count from Mail.app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get unread message count from Mail.app


  • Subject: Re: Get unread message count from Mail.app
  • From: Deivy Marck Petrescu <email@hidden>
  • Date: Sat, 16 May 2009 17:34:20 -0400


On May 16, 2009, at 16:42, Philip Aker wrote:

On 2009-05-16, at 13:15:59, Michelle Steiner wrote:

On May 16, 2009, at 11:40 AM, Philip Aker wrote:

"Get Mail's unread message count so it matches the number on its icon badge in the dock."

In 10.5, the user can choose whether the number shown on the Dock is all unread messages, just the unread ones in the inbox, or none at all.

1. Too slow

tell application "Mail" to count (every message of every mailbox whose read status is false)

This took less than one second for me:

--set a to current date
tell application "Mail"
tell mailboxes
count of (messages whose read status is false)
end tell
end tell
--(current date) - a

Mac OS X10.5.7, mail 3.6 (935/935.3) iMac Core 2 Duo, 2.06 GhZ (Last of the "white" modes before the silver ones).  It's the only one I have, so the only one I could test.

Unfortunately:

set a to current date
tell application "Mail"
tell mailboxes
set urc to count of (messages whose read status is false)
end tell
end tell
{urc, (current date) - a}

--> {1299, 27}

takes 27 seconds on my setup. Insufferable for the OP (who wants to create a Dock-like application).

ยง

The problem (with tell application "Mail" to set res to unread count of mailboxes variants) as reported is:

"That's not working correctly for me at all. "mailboxes" is only returning {mailbox "ToDos" of application "Mail", mailbox "Outbox" of application "Mail", mailbox "Deleted Messages" of application "Mail"}, which is far from correct"

So I'm trying to determine how he has arrived at an account/mailbox setup which would give him an invalid count when mine is 100% accurate.


Philip Aker

Philip,
Does that script really return something for you?
I've ran it many times and it never gets the right number.
The only answer I get with Michelle's script is 0.



Deivy Petrescu
email@hidden





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Get unread message count from Mail.app
      • From: Philip Aker <email@hidden>
References: 
 >Get unread message count from Mail.app (From: Philip Aker <email@hidden>)
 >Re: Get unread message count from Mail.app (From: Michelle Steiner <email@hidden>)
 >Re: Get unread message count from Mail.app (From: Philip Aker <email@hidden>)

  • Prev by Date: Re: Home to top of the list.
  • Next by Date: Re: Home to top of the list.
  • Previous by thread: Re: Get unread message count from Mail.app
  • Next by thread: Re: Get unread message count from Mail.app
  • Index(es):
    • Date
    • Thread