I’m familiar with a few programming languages but AppleScript is new to me (and it looks pretty powerful and useful, makes me wonder why I didn’t learn it before…).
I recently learned of the existence of an app called “Notification Scriptings” ( http://www.cooperative-fruitiere.com/notifications/index_en.html ) that lets you create custom Notification Center notifications using AppleScript.
So I looked at Outlook’s dictionary to see what I could do and with a rule set in Outlook 2011 to execute my script every time an email comes in, I can get notifications for every message.
My only problem, is what happens when you click the notification…
The “Message” object seems to be temporary so the only way I can store something long term is by storing the message in the user info argument, I think…
So, here’s my script. It shows notifications (also I made a custom copy of Notifications Scriptings and copied Outlook’s icon in it so everything looks native
property theMessages : null
tell application "Notifications Scripting"
set subtitle to ""
set thebody to ""
-- This is required for calling the user notification event handlers. The handlers can be in a different script file.
set event handlers script path to (path to me)
-- The user info parameter is a record. The supported data types are text, integer, real, boolean, date, alias, file and POSIX file.
set dict to {theName:"Notifications Scripting", theVersion:"1.0", theScript:event handlers script path}
-- Create a notification. Only the title is required at minimum.
-- Use "Default" for the default sound played by the user notification center.
-- See the Notifications Scripting dictionnary for more informations.
tell application "Microsoft Outlook"
set theMessages to current messages
end tell
set theMessageCount to count theMessages
tell application "Microsoft Outlook"
repeat with a from 1 to 1
tell item a of theMessages
set theSubtitle to subject
set thebody to plain text content as string
end tell
--open item a of theMessages
end repeat
end tell
--set theThing to {Message:item 1 of theMessages, number:2}
display notification "Outlook" subtitle theSubtitle message thebody sound name "Default" --user info theThing
end tell
using terms from application "Notifications Scripting"
-- This handler is called when a notification was delivered.
-- All parameters are optionnals.
on notification delivered title aTitle subtitle aSubTitle message aMessage actual delivery date aDeliveryDate user info aDict
tell application "Finder"
--display dialog aTitle & return & aDeliveryDate & return & (theScript of aDict) as text
end tell
end notification delivered
-- This handler is called when a notification was activated.
-- All parameters are optionnals.
on notification activated title aTitle subtitle aSubTitle message aMessage delivered date aDeliveryDate activation type aType user info theMessageThing
tell application "Microsoft Outlook" to activate
end notification activated
end using terms from
It’s working fine but redirecting to the right message would make that script act just like a native Outlook Notification Center integration might look like…
How could I tell outlook to open the right message?
Is it even possible?
Thanks
EDIT: Yes the names of my variables are absolutely awful. I am aware of that…
Browser: Safari 536.30.1
Operating System: Mac OS X (10.8)