Using MacPorts, there is a program called “Terminal Notifier” that can send alerts to Notification Center in Mountain Lion based off of a command line entry and thus an Applescript. Obviously, you can have a lot of fun with that – but I specifically found it so that I could send a new message alert from Outlook because Microsoft only has such a notification appear on the active desktop and I use several of them in Mission Control. I compiled this information from these sites:
http://osxdaily.com/2012/08/03/send-an-alert-to-notification-center-from-the-command-line-in-os-x/
https://github.com/alloy/terminal-notifier
To get this to work isn’t so bad once you have MacPorts installed, which I’ve referenced earlier.
- Assuming MacPorts is already installed, run the selfupdate command (also listed in that earlier post).
- Install Terminal Notifier:
sudo port install terminal-notifier
- Download and put this AppleScript into your Documents/Microsoft User Data/Outlook Script Menu Items (you don’t have to put it there, but just for organizational sake, might as well). Sure it says Growl in everything below as that is what I originally used it for but then changed it to accommodate Notification Center instead:Improved Growl New Mail.scpt
That’s all there is to it.
-j
Hi,
I tried the above procedure, for some reason i’m getting this error from your script:
–> error number -1728 from «class PlTC» of incoming message id 689
do shell script “/opt/local/bin/terminal-notifier -message ” -title ‘Password Alert’ -subtitle ‘ITSecurity’ -activate com.microsoft.outlook”
it seems that this part of the code is the problem:
— content, truncated to 30 characters
try
set mycontent to «class PlTC» of theMsg
set mycontentlen to (length of mycontent)
if (mycontentlen > 30) then
set mycontent to (text 1 thru 29 of mycontent) as string
end if
can you please help me?
Thanks.
Are you able to run terminal-notifier from a Terminal window? Can you run this command without any issues:
/opt/local/bin/terminal-notifier -message “MessageTest” -title “TitleTest” -subtitle “SubTitleTest” -activate com.microsoft.outlook
Hi!
Thanks a lot for your post, I had to switch to Outlook because of the Exchange server we’re using (Apple Mail was not syncing well), and the basic notification windows was just awful in Outlook!
Just a small info for those who don’t have MacPorts and don’t want to go through the hassle of installing it, you can download a binary version of terminal-notifier there: https://github.com/alloy/terminal-notifier/downloads
After unzipping, put terminal-notifier.app wherever you want, for instance in the Application folder. The open Improved Growl New Mail.scpt with Applescript Editor, and at the end, update the terminal-notifier command as follows:
do shell script “/Applications/terminal-notifier.app/Contents/MacOS/terminal-notifier -message ” & quoted form of mycontent & ” -title ” & quoted form of mysubject & ” -subtitle ” & quoted form of mysender & ” -activate com.microsoft.outlook”
For those who also dislike Outlook’s sound for new messages, you can just add
do shell script “afplay /System/Library/Sounds/Glass.aiff”
Cheers!
Also, there was small bug with the script when there was no subject in the message.
A possible fix is to replace “set mysubject to subject of theMsg” by
— subject
try
set mysubject to subject of theMsg
if mysubject is missing value then
set mysubject to “No subject”
end if
on error errmesg number errnumber
set mysubect to “No subject”
end try
Thanks for the good info! I’ll update the script posted here.
-j
If you add -m sender com.microsoft.outlook it will display the Outlook icon instead of the terminal icon with the version of terminal-notifier that I have
Sorry, typo that should be -sender com.microsoft.outlook