******* DONE External Links to Outlook Emails Get Broken When Emails Are Moved :blog:microsoft:software:pim:programming:emacs: CLOSED: [2018-01-24 Wed 14:21] :PROPERTIES: :ID: 2018-01-24-broken-outlook-links :CREATED: [2018-01-24 Wed 14:02] :END: :LOGBOOK: - State "DONE" from "DONE" [2022-03-15 Tue 14:44] - State "DONE" from "NEXT" [2018-01-24 Wed 14:21] :END: - Update 2022-03-15: Email from Eric A [[https://www.reddit.com/r/emacs/comments/4gtqhk/windows_users_what_email_client_are_you_currently/d2lvitd/][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: #+BEGIN_EXAMPLE ' 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 #+END_EXAMPLE 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 [[https://github.com/novoid/dot-emacs/blob/master/config.org#links-to-outlook-entities][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. [[https://stackoverflow.com/questions/42986796/hyperlink-to-an-existing-outlook-mail-message][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 :PROPERTIES: :END: #+BEGIN_QUOTE 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 [[https://camiel.bouchier.be/en/cb_thunderlink][cb_thunderlink addon]] to Thunderbird. #+END_QUOTE 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.