• 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
Checking unread email account in Mail.app and Outlook 2011
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking unread email account in Mail.app and Outlook 2011


  • Subject: Checking unread email account in Mail.app and Outlook 2011
  • From: "David A. Cox" <email@hidden>
  • Date: Fri, 19 Nov 2010 22:38:15 +0000
  • Thread-topic: Checking unread email account in Mail.app and Outlook 2011

I have a need to see how many unread email messages I have across multiple
email programs, and I thought I would share my current script to gather
this info from mail.app and outlook 2011 in case it is of any interest to
others, and to see if people have a more efficient solution to any of the
steps here, or other suggestions as to how to improve this script.

My current working script is:


--Lets make lets find out what processes are running, so we don't launch a
mail program if one is not running.

--First we need a variable we can set to true when we find a mail program,
and then some variables we can add together in case multiple mail programs
are running.
set foundMailProgram to false
set AppleMailCount to 0
set OutlookCount to 0
set totalUnread to 0

tell application "Finder"
 set procs to the name of every process
end tell



if "Mail" is in procs then

 --First, lets find out how many messages are in our colective "Inbox"
 set foundMailProgram to true
 tell application "Mail"
  repeat with thisAppleMailAccount in every account
   set thisAppleMailInBox to mailbox named "INBOX" of thisAppleMailAccount
   set thisAppleMailUnreadCount to unread count of thisAppleMailInBox
   set AppleMailCount to AppleMailCount + thisAppleMailUnreadCount
  end repeat

 end tell
end if

--We may have to deal with the case where you are a deligate of another
person's calendar, as that wants to include those unread message if you
have actually see those calendars
if "Microsoft Outlook" is in procs then
 --First, lets find out how many messages are in our colective "Inbox"
 set foundMailProgram to true
 tell application "Microsoft Outlook"
  repeat with thisOutlookMailAccount in every exchange account
   set OutlookUnreadCount to 0
   try --we use a try to avoid blocks when we are a deligate of an inbox
we can not read
    set thisOutlookMailInBox to mail folder "Inbox" of
thisOutlookMailAccount
    set OutlookUnreadCount to count of (messages of thisOutlookMailInBox
whose is read is false)
   end try
   set OutlookCount to OutlookCount + OutlookUnreadCount
  end repeat

  repeat with thisOutlookMailAccount in every imap account
   set thisOutlookMailInBox to mail folder "Inbox" of
thisOutlookMailAccount
   set OutlookUnreadCount to count of (messages of thisOutlookMailInBox
whose is read is false)
   set OutlookCount to OutlookCount + OutlookUnreadCount
  end repeat

 end tell
end if

--If we found a mail program running, lets add up the unread messages, and
do some stuff with that number.
if foundMailProgram is true then
 set totalUnread to AppleMailCount + OutlookCount
 return "There are " & totalUnread & " unread messages across all your
mailboxes"
else
 return "There were no running email programs to check for mail"
end if


 _______________________________________________
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

  • Prev by Date: Outlook 2011 script to get 'next meeting'
  • Next by Date: Re: count of Finder windows: Is this a bug?
  • Previous by thread: Outlook 2011 script to get 'next meeting'
  • Next by thread: How to adjust this script to work on Snow Leopard?
  • Index(es):
    • Date
    • Thread