I have seen a few scripts for showing sender and subjects of unread email from your Gmail account. But there isn't a script that extract the same information from the Mail.app. So I've put together script that will do the following:
- If Mail is open, and there isn't any unread messages, it will show nothing, as to not be obstructive.
- If Mail is open, and there is some unread message, it will show all the unread messages in the format of "Sender: Subject"
- If Mail is not open, it will show "Mail not open", to remind you why you might not see any unread message. (If this is not needed, simply remove the 2nd and 3rd lines from the bottom of the script.
Anyhow, here's the script:
tell application "System Events"
set processList to (name of every process)
end tell
if processList contains "Mail" then
tell application "Mail"
if (unread count of inbox) > 0 then
set messageList to (messages of inbox) whose read status is false
set output to ""
repeat with itemNum from 1 to (unread count of inbox)
set output to output & (extract name from sender of item itemNum of messageList) & ": " & subject of item itemNum of messageList & return
end repeat
end if
end tell
else
set output to "Mail not open :("
end if
Save the script somewhere, and create a Shell geeklet with something like:
osascript ~/Documents/Scripts/UnreadMessages.scpt
Feel free to give suggestions and recommendations :)