Creating a mailto: bookmark

I’m trying to bookmark a mailto: url in Hook. I realise that’s not a context, but is it possible some way to create a new email from a Hook bookmark? (My email program doesn’t have a url scheme)

That’s an interesting question. In short, the New Item integration framework wouldn’t work well for this because the script is expected to return the URL of the new item, and Hook is designed to open that URL. However in the case of email, the URL cannot normally be constructed because the mail message wouldn’t have a URL yet because the RFC-5322 ID is not (normally) available until the message is sent. The New Item script for the mail app could in principle return a predetermined or algorithmically determined link (e.g., to a pertinent hook file), but that would get hooked to the source. There’s no mechanism / configuration to override this expectation. We could have named the “New Item” tab “hook to new item” but that would have been a bit long for a tab name.

But if you didn’t mind (a) the spurious hook or (b) the error message from not returning a URL, then you could edit the New Item script of your email app. If the email app has an API to create a new email with subject and body, then you could use it in the New Item script. It could use the $title and/or $user_link in subject and/or body. If the email app doesn’t have automation, but is your default email app, you could create your own mailto: URL in AppleScript and populate it with information from the bookmark. Compare Setting Up an Email Message - AppleScript in a Nutshell [Book].

Regarding (a) I suppose the New Item script could call an app that would launch a non-blocking asynchronous process (running after it returns) that would wait a few seconds and then delete the new hook. Not pretty.

I would recommend instead creating a little AppleScript that leverages Hook’s automation to get the title and name of the current resource and create the email with it. Once it’s sent, then a bit of automation could hook them together.

Down the road, we could extend Hook to make scripts readily available from the Title menu so users could launch them from within Hook. Analogous to macOS services.

1 Like