Using AppleScript, is it possible to check for unread emails? -


i found out applescript, , i'm in process of learning. i'd create that'll check email see if have new email. if yes, want return value (i.e. "mail"). if not, want return different value (i.e. "no mail"). idea use mail application achieve this.

looking @ dictionary mail application (http://www.mugginsoft.com/html/kosmictask/asdictionarydocs/apple/mail/os-x-10.7/mail-5.2/html/), doesn't possible since doesn't seem can check unread mails in particular.

yes, possible. used use geektool show list of read messages hadn’t dealt yet.

in case, it’s easier, since don’t want keep list of unread messages, exit discovered.

the flag you’re looking “read status”.

tell application "mail"     if exists (messages of inbox read status false)         "mail"     else         "no mail"     end if end tell 

note have looking in particular mailbox; in case, i’m looking @ inbox. if presorting messages other mailboxes using rules, i’m not aware of way of doing using applescript without checking each mailbox separately. (though might possible using sqlite directly on mail’s database file.)

this might work if need unread mail in other mailboxes:

tell application "mail"     if exists (messages of inbox read status false)         return "mail"     else         repeat box in mailboxes             tell box                 if exists (messages read status false)                     return "mail"                 end if             end tell         end repeat     end if     return "no mail" end tell 

however, anecdotal experience if have complicated setup, running scripts (and including one) tend mail’s smart (and dumb) mailboxes out of sync read status of messages within them.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -