Thank you, @rkaplan. I had a quick look and this seems doable and would be worthwhile! (I haven’t discussed it with the dev team yet, but I’ve updated the ticket accordingly.)
That would be awesome. I moved to Outlook when my firm’s case management system released an Outlook add-in. Right now, I’m doing the song and dance in the link in the post from @rkaplan. Would be awesome if I could use Hook instead.
Thank you so much for sharing this, @rkaplan. I had to tweak it somewhat – for some reason my Office 365 links looked a little different than yours – but I have it working. I couldn’t get it working for items in a user-created folder, as the link included some symbols inserted in the middle of it, and my regex isn’t strong enough to figure out how to remove them. But I just act on items in my archive, inbox, and sent items anyway. Thanks again.
a dev here proposed this, should anyone want to try this version:
tell application "Safari"
set d to first item of documents
set u to URL of d
if u contains "https://outlook.office.com/mail/inbox/id/" then
set AppleScript's text item delimiters to "https://outlook.office.com/mail/inbox/id/"
set messageID to text item 2 of u
return "https://outlook.office.com/owa/?ItemID=" & messageID & "&viewmodel=ReadMessageItem&path=&exvsurl=1"
end if
return u
end tell
You’d need to open the email in its own tab, then call Hook to Copied Link. This is because MS does not expose the title in the message list view (or whatever MS calls it).
Here is a revised script:
tell application "Safari"
set d to first item of documents
set u to URL of d
set outlookUrl to "https://outlook.office.com/mail/inbox/id/"
if u contains "https://outlook.office.com/mail/inbox/id/" then
set AppleScript's text item delimiters to "https://outlook.office.com/mail/inbox/id/"
set messageID to text item 2 of u
if messageID contains "?" then
set AppleScript's text item delimiters to "?"
set messageID to text item 1 of messageID
end if
return "https://outlook.office.com/owa/?ItemID=" & messageID & "&viewmodel=ReadMessageItem&path=&exvsurl=1"
end if
return u
end tell
We’re looking into a solution that would be browser-agnostic.
I played around with this for a few minutes, and, assuming I’m doing it correctly, it works great on messages in the Inbox, but not on messages in the Archive, Sent Items, or other folders. It’s quite possible, though, that it’s user error on my part.
I know it is possible to get links in standard Office 365 folders, as I have a Keyboard Maestro macro that grabs links from any standard folder (Archive, Deleted Items, Sent Items, etc.), and reformats them so they can be re-opened later. (I can’t get it to work with custom folders, though).
We need to revise the script to reflect the format of the URL for other mailboxes - in my KM Forum post I noted that this Regex replace solves that - we need to do something similar for the Hook script: