Outlook email links

I have noticed that Outlook for web now exposes the message ID, if a message is selected (tested on Office 365).

So I have asked an LLM to write me a bookmarklet and with a bit of testing I got the following which copies a functioning markdown link to the message (and adds any selected text in the browser to the clipboard with it). Works best when messages are not grouped into conversations. Hope it is of use to someone and that one day something similar can be built into the official clipper.

javascript:(function() {
    var url = window.location.href;
    var match = url.match(/\/id\/([^/]+)/);
    if (match && match[1]) {
        var messageID = match[1];
        var permanentUrl = 'https://outlook.office.com/owa/?ItemID=' + messageID + '&viewmodel=ReadMessageItem&path=&exvsurl=1';
        
        var selectedText = window.getSelection().toString().trim();
        var markdownLink = '[(message link)](' + permanentUrl + ')';
        
        var result = selectedText ? '"' + selectedText + '" ' + markdownLink : markdownLink;
        
        var tempInput = document.createElement('input');
        document.body.appendChild(tempInput);
        tempInput.value = result;
        tempInput.select();
        document.execCommand('copy');
        document.body.removeChild(tempInput);
        
        alert('Copied to clipboard:\n' + result);
    } else {
        alert('Could not find message ID in the current URL. Make sure you\'re viewing a specific email in Outlook Web App.');
    }
})();

Hello @zinoff ,

Pretty cool! Thanks a lot for sharing the code, and such a possibility. I hope we’ll include support of Outlook for web into the next WebClipper release :slight_smile:

Added to our Bookmarks enhancements list.

Thanks a ton again!
KIR

I’ve asked the usual LLM to combine the nice bookmarklet here GitHub - finnchr/checkvist-bookmarklet: Checkvist bookmarklet and encode differently the url in case the url is outlook.office.com. It seems to work on Chrome. Again it works when the messages in outlook are not displayed in conversation mode.

javascript:(function(){
    var url = window.location.href;
    var permanentUrl = url;
    if (url.startsWith("https://outlook.office.com")) {
        var match = url.match(/\/id\/([^/]+)/);
        if (match && match[1]) {
            var messageID = match[1];
            permanentUrl = 'https://outlook.office.com/owa/?ItemID=' + messageID + '&viewmodel=ReadMessageItem&path=&exvsurl=1';
        }
    }
    var sel = window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection ? document.selection.createRange().text : "",
    a = window, b = document, c = encodeURIComponent, d = new Date().getTime(),
    e = a.open("https://checkvist.com/checklists/?add_popup=1&d=" + d + "&import_cotent=[link:" + c(b.title) + "|" + c(permanentUrl) + "]&import_cotent_note=" + c(sel),
    "bkmk_popup", "left=" + ((a.screenX || a.screenLeft) + 10) + ",top=" + ((a.screenY || a.screenTop) + 10) + ",height=380px,width=480px,resizable=1,alwaysRaised=1");
    a.setTimeout(function(){e.focus()}, 300);
})();
1 Like

Ehm, I have should have done my testing a bit more thoroughly…

The outlook link will only work if you don’t move the email message from the folder where it was linked originally.

So the bookmarklet at the end turns out to be a lot less useful than what I had originally thought.