- Update 2022-03-15: Email from Eric
A reddit post gave me the idea to link Outlook emails within my Org-mode. Unfortunately, this method comes with some drawbacks.
Setup
I registered the link type in the Windows registry, added the VBA code below and made it work from the command line:
' Adds an Org-mode link to the currently selected message to the clipboard: Sub AddLinkToMessageInClipboard() Dim objMail As Outlook.MailItem Dim doClipboard As New DataObject 'One and ONLY one message must be selected If Application.ActiveExplorer.Selection.Count <> 1 Then MsgBox ("Select one and ONLY one message.") Exit Sub End If Set objMail = Application.ActiveExplorer.Selection.Item(1) doClipboard.SetText "[" + Format(objMail.ReceivedTime, "yyyy-mm-dd ddd Hh:Nn") + _ "] [[outlook:" + objMail.EntryID + "][Email: " + _ Replace(Replace(objMail.Subject, "[", "{"), "]", "}") + " (" + _ objMail.SenderName + ")]]" doClipboard.PutInClipboard End Sub
After adding a Quick Access Toolbar item which gave me direct access to the functionality, I get clipboard content like this:
[2018-01-24 Wed 13:27] [[outlook:00000000CC2...1054E0][Email: Testsubject (Karl Voit)]]
Please note that the actual ID is much longer. In cmd.exe
the following command now works:
"C:/Program Files (x86)/Microsoft Office/Office16/OUTLOOK.EXE" /select outlook:00000000CC2...1054E0
Clicking the link within Emacs works after I added this lisp code to my Emacs config.
Please note, that even the location of OUTLOOK.EXE
is a subject to change. Its location on my Office 2016 changed from C:\Program Files (x86)\Microsoft Office\Office16
to C:\Program Files\Microsoft Office\Office16
during a simple Office update.
Where It Fails
Now you will recognise, that these IDs are changing according to the time and the folder the associated email is stored to. This means that you'll get different IDs for the same email when it is in your inbox, stored to your archive folder and even once again when stored back to your inbox.
This page shows some attempts using PR_SEARCH_KEY
or Outlook Links which fail as well.
To my knowledge, there is no possible way to get a unique ID to an Outlook email which does not change when email is moved to folders.
Hence, this linking method only works as long as you link emails only from their final storage location.
Email Comment by Eric
Hello,
I wonder whether an alternative approach could be to generate not a link to a specific message ID, but rather a link that would launch outlook and search for, say, the message author + date, which would almost surely return only the wanted message (or multiple copies of it if there are). This is the approach introduced (for different reasons) in the cb_thunderlink addon to Thunderbird.
Yes, this would be an approach to fix this issue with Outlook. Depending on the API exposed by Outlook via command line, this might be feasible to implement.
I, myself, don't have access to Windows any more (lucky me). So I won't follow that train unless I'm forced to use Windows again in the future.