• 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
Get unread message count from Mail.app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Get unread message count from Mail.app


  • Subject: Get unread message count from Mail.app
  • From: Philip Aker <email@hidden>
  • Date: Sat, 16 May 2009 11:40:02 -0700

Here's a problem which originated on the Carbon list. 

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

What is needed is something fast which works on all kinds of setups.
Can anyone verify #4? 

1. Too slow

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

2. Doesn't work on all setups:

set sum to 0
tell application "Mail" to set res to unread count of mailboxes
repeat with i in res
set sum to sum + i
end repeat
sum

3. Doesn't work on all setups:

tell application "Mail"
set msgCount to {}
repeat with thisAccount in (every account whose enabled is true)
set end of msgCount to (unread count of every mailbox of thisAccount)
end repeat
msgCount
end tell

4. Latest version of #2. Can't verify if it works on all setups:

set sum to 0
tell application "Mail"
set alist to every account whose enabled is true
repeat with a from 1 to count of alist
set res to unread count of every mailbox
repeat with i in res
set sum to sum + i
end repeat
end repeat
sum
end tell

Thanks!

Philip Aker
echo email@hidden@nl | tr a-z@. p-za-o.@

Democracy: Two wolves and a sheep voting on lunch.

 _______________________________________________
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: Michelle Steiner <email@hidden>
  • Prev by Date: Re: Home to top of the list.
  • Next by Date: Re: Get unread message count from Mail.app
  • Previous by thread: Re: Home to top of the list.
  • Next by thread: Re: Get unread message count from Mail.app
  • Index(es):
    • Date
    • Thread