Using Hook with Outlook for Mac

I use the following custom scripts with Outlook for Mac. I also use the Outlook handler here to make it a bit cleaner and simpler - set the Hook URL scheme to hook://outlook/document-identifier

Get Name:

tell application "Microsoft Outlook"
    set theMessage to first item of (get current messages)
    set theSubject to the subject of theMessage
end tell

get theSubject

Get Address:

tell application "Microsoft Outlook"
	set theMessage to first item of (get current messages)
	set theID to the id of theMessage
	set the clipboard to {text:(theID as string), Unicode text:theID}
	
	
end tell

get "outlook://" & (the clipboard)

3 Likes

Thank you @Corkstu ! I’ve copied this to our internal issue to support Outlook, so that other users can benefit.

Thanks again, @Corkstu. The latest version of Hook now has support for Outlook, including some of the above code.

All: please note that Outlook is not handled as a regular Hook email client.

Our developer notes:

We can integrate Outlook, but not as a proper Hook integrated email client. Hook can create and connect and open links to Outlook messages but they’re not links which are compatible with other mail clients and which work on other machines

The problem is Open Item. We can generate correct hook://email/message-id URLs but opening them in Outlook is too slow to be useable.

Outlook doesn’t use message-id to identify messages, so have to parse and check the header of every single message in outlook to find a match for a given message-id, which can take a long time.

Outlook provides its own unique identifiers which we can use to create and open links to messages, but they are not cross compatible with other email clients, and you can’t send them to anyone else.

We would need to ask Microsoft to ensure Outlook exposes the real message-id per Section 3.6.4 of RFC 5322 - Internet Message Format .

Happy to be involved and help. Thank you for chasing the background/options with Microsoft. You did the professional developer thing, I did the quick and dirty fix!

1 Like

Hello Guys,
Recently came across Hook and have loved it thus far. I have been experimenting with DevonThink, browsers (Firefox, Chrome) and some note taking apps (Quiver and Bear et al). But I am running into a roadblock with Microsoft Outlook. It looks like Hook does work with Outlook and other folks have been able to make it work, but I have spend the last 2 hours trying to figure out how do I make outlook emails work with hook. I would appreciate any help (I guess some sort of a step by step instruction?) here.

Here is what I have tried:

  1. Copied the two scripts in mentioned in https://github.com/acidix/OutlookURLHandler in their relevant directories - I have verified the directory path to be correct and also tried removing and putting back those scripts.

  2. Ran the URLHandler script.

  3. Created an Alfred Workflow (also tried with BetterTouchTool) to trigger the MsgLnkToClipboard script. Even tried triggering the script manually. In each of these script runs, I made sure that a valid email is selected on my outlook (an email that was not in draft, and is fully downloaded), but I keep getting the error that says “Selected message is an Event / Reminder. Please select an E-Mail message.” even though the message I have selected is not an event or a reminder. I just could not generate the link.

  4. I also noticed that there are some scripts in Hook preferences for Outlook such as for Open Item, Get Name etc. I do not know whether I should be using these scripts instead - and if so, how should I use these scripts.

I looked up the YouTube videos for Hook for some hints but I feel lost. Would appreciate any help and I am sorry if this is a very basic question.

Thank you!

welcome to the Hook Productivity Forum, @pralayb. Sorry for the delay in responding. I blew out my Outlook test setup recently, and need to re-establish it.

Have you checked whether you’ve given Hook permission to access Outlook , per Accessibility Permissions – Hook. That’s usually the issue.

Also: if there is a Reminder, then Outlook’s AppleScript does not return the right result. Dismissing the reminder fixes the issue.

Otherwise, could you please let us know the version of Outlook that you are using, and of macOS? For the other MS Office apps: versions prior to 2016 are not supported.

Does Hook’s contextual window’s status bar show “No linkable item found” in Outlook when you invoke it in Outlook on emails you have received and sent, rather than on drafts. We would not expect drafts to be linkable because they don’t have a URL.

Also if you could send us a screenshot, that might help.

thank you.

@pralayb
@LucB LucB

I can provide additional detail - I’m having the same issue.

Outlook version: 16.38
screenshots attached too.Screen Shot 2020-06-08 at 11.21.46 PM

welcome to the Hook Productivity Forum, @damboyan. And thank you for posting.

could someone with the problem please try pasting the following code in Apple’s Script Editor (not Hook’s) while a message is selected, and running it, and see what gets returned?

`tell application "Microsoft Outlook"
set msg to first item of (get current messages)
get "outlook://" & id of msg
end tell`

Thank you.

@LucB Thanks for the reply! Tried the provided script and received this result:

error “Can’t get item 1 of {}.” number -1728 from item 1 of {}Screen Shot 2020-06-09 at 6.16.34 PM

@LucB any suggestions?

This seems to mean you are running an Insider Fast (aka “beta”) version of Outlook.

Compare: Outlook for Mac - Release notes for Insider Fast builds - Office Support.

Two of us here at CogSci Apps tested with Outlook version: 16.16 which is the latest official (non-beta) build from MS. It works fine. And our AppleScript test yields a different (and correct) response.

Perhaps Microsoft’s beta builds use a different bundle ID and maybe use a different app name. To verify, would you please run the following from the Terminal app, which normally lives in the
[/Applictions/Utilities folder](hook://file/V3vwC2mqk?p=Ly9BcHBsaWNhdGlvbnM=&n=Utilities) :

osascript -e 'id of app "Outlook"'

That command should return com.microsoft.Outlook . That is the bundle ID of the app. If not, that would explain the Hook issue. We could easily remedy that.

If that is not the issue, it suggests a bug with MS Outlook. (The AppleScript response you suggests a bug on the Outlook side.) Here are some notes on that: Join | Office Insiders

to quote them:

Best for Insiders who want to use the very earliest builds to identify issues and provide feedback about new features still in development. Insider is ideal for those who don’t mind the bit of risk involved in using unsupported builds.

If there’s a bug with their beta, it would be helpful for Outlook Insider Fast users, and CogSci Apps, to report the problem to MicroSoft. But first things first.

Similar issue on my side; Hook seems to not work with Outlook.

Outlook version is 16.38 (20052612).

The id of app Outlook is com.microsoft.Outlook.

Microsoft Update is set to “Production”.

OK over here it is working now. What is not working is linking outlook calendar entries.

From the MsgLinkToClpbrd.scpt it sounds as if it should be possible, as it is looking at the “class” of the item selected.

Anyone knows how to hook outlook calendar entries?

Hi @damboyan ,

if you have overridden the Outlook script in Hook then, assuming your issue was similar to @eMaX’s above, deleting your override would revert to Hook’s built in version of this script, and solve your problem.

Here’s how: in Hook > Preferences > Scripts pane. Overridden scripts have a * in left pane. You can remove the override by clicking the - button on bottom left when the script is selected. Just select the Outlook script on the left and click the - button at the bottom left of the pane.

(A Bear user ran into the same thing with respect to Bear last year: Hook+Bear+OmniFocus).)

It doesn’t look that it is overridden…

But then, it’s working, only not for calendar entries (where I’d use it most, since it would allow me to hook all related documents to a meeting)
Screen Shot 2020-06-15 at 18.10.26

Hello @LucB, @damboyan and fellow Hook users,

Thank you for all your responses - unfortunately, I haven’t been able to get this to work still. I am pasting the relevant information below. I would really appreciate if someone could lay down step-by-step directions to get this to work.

D7BB88CF-61B2-4E67-B199-93A0F9BC683C

Right clicking the image and hitting “open link in a new tab” shows the full-scale image with zoom to see the text clearly. I apologize for this inconvenience - I did not know of a better way to provide all the information.

Thank you,
Pralay

Looks like even on the “Production” channel, the “New Outlook” mode breaks AppleScript support - see this thread on Microsoft UserVoice - and upvote!

Hi

Sorry to bump this, but what is the latest on this? Is there a new thread?

I am still having the same issue.

Sorry for the trouble.

Are you using New Outlook or the old one? Hook does not work with New Outlook because it does not support AppleScript.

If you are using the old Outlook, could you please provide more info to us, such as the Hook script version (you can get it from Hook preference window->Update tab), Hook version, and some screen shots.

Thank you