Can I create a link to a specific email message in Outlook?

69

36

I use Outlook as my email client at work, but I don't want to use it to manage my tasks and todos. (Instead I use plain text files and Emacs org-mode.) Since many todo items start out as mails in my inbox, I often need to reference these mails.

Is there some clever way to create a link (a URL) that opens a specific email in Outlook when clicked?

Christian Berg

Posted 2009-11-17T19:09:46.233

Reputation: 813

Answers

32

You can do this with a little bit of code in Outlook and a little bit of code in Emacs.

First, if you're using Outlook 2007 you'll need to enable Outlook URLs with a registry addition. Instructions and the registry file can be found here courtesy of David Tan.

Next, this macro can be added to Outlook and will get the GUID of the current email message, create a Org-Mode link and deposit it into the clipboard.

'Adds a 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 muse 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 "[[outlook:" + objMail.EntryID + "][MESSAGE: " + objMail.Subject + " (" + objMail.SenderName + ")]]"
   doClipboard.PutInClipboard

End Sub

As koushik noted in the comments, the doClipboard.SetText part can be expanded to differentiate between different item types:

If objMail.Class = olMail Then
    doClipboard.SetText "[[outlook:" + objMail.EntryID + "][MESSAGE: " + objMail.Subject + " (" + objMail.SenderName + ")]]"
ElseIf objMail.Class = olAppointment Then
    doClipboard.SetText "[[outlook:" + objMail.EntryID + "][MEETING: " + objMail.Subject + " (" + objMail.Organizer + ")]]"
ElseIf objMail.Class = olTask Then
    doClipboard.SetText "[[outlook:" + objMail.EntryID + "][TASK: " + objMail.Subject + " (" + objMail.Owner + ")]]"
ElseIf objMail.Class = olContact Then
    doClipboard.SetText "[[outlook:" + objMail.EntryID + "][CONTACT: " + objMail.Subject + " (" + objMail.FullName + ")]]"
ElseIf objMail.Class = olJournal Then
    doClipboard.SetText "[[outlook:" + objMail.EntryID + "][JOURNAL: " + objMail.Subject + " (" + objMail.Type + ")]]"
ElseIf objMail.Class = olNote Then
    doClipboard.SetText "[[outlook:" + objMail.EntryID + "][NOTE: " + objMail.Subject + " (" + " " + ")]]"
Else
    doClipboard.SetText "[[outlook:" + objMail.EntryID + "][ITEM: " + objMail.Subject + " (" + objMail.MessageClass + ")]]"    
End If

Almost there, add this little bit of lisp to your emacs lisp directory to enable Outlook links.

;;; org-outlook.el - Support for links to Outlook items in Org

(require 'org)

(org-add-link-type "outlook" 'org-outlook-open)

(defun org-outlook-open (id)
   "Open the Outlook item identified by ID.  ID should be an Outlook GUID."
   (w32-shell-execute "open" (concat "outlook:" id)))

(provide 'org-outlook)

;;; org-outlook.el ends here

And lastly, update your .emacs file to include the Outlook link code. Just add this somewhere after org-mode is setup.

(require 'org-outlook)

Now you can call the macro (I added it to my toolbar in Outlook for quick access) and you can quickly create a link to the email in Emacs.

One gotcha, GUID's change when you move a message between document stores, so if you get the GUID to the message while it's on your Exchange server and then move it to your local PST file the link will change. Move the message before you get the GUID.

user25995

Posted 2009-11-17T19:09:46.233

Reputation:

4This is great, thank you! One simplification: I didn't mess with the registry to enable Outlook URLs, instead I just changed the w32-shell-execute call to this: (w32-shell-execute "open" "C:/Programme/Microsoft Office/Office12/OUTLOOK.EXE" (concat "/select " "outlook:" id) – Christian Berg – 2010-01-26T15:17:31.090

I got a unknown type error for DataObject. After trying out various options such as add reference to Microsoft Forms which was not available for adding, and others I came across https://www.excelforum.com/excel-programming-vba-macros/338020-dataobject-and-cliboard.html and added a dummy userform and it started working

– Miserable Variable – 2018-10-31T21:47:43.903

Any pointers to a macOS equivalent? – Paul Bissex – 2019-05-08T12:32:54.817

2To solve the DataObject type error, the following worked for me. In the macro editor, go to Tools->References. Click browse, select the file C:\Windows\System32\fm20.dll and press OK. – Hugo Ideler – 2019-05-09T18:40:17.947

@HugoIdeler: Note that on x64 systems, the location of the dll is C:\Windows\SysWOW64 – Thomas – 2019-09-12T13:04:24.370

1Thanks for this answer. I found out that I somewhat needed to create an empty form to prevent compilation error on undefined DataObject. – Laurent' – 2011-11-05T13:24:12.670

@ChristianBerg: I'm using Outlook 2003, so maybe I can have hyperlinks without bothering with the registry, but your simplification did not work, Outlook was unable to find the URL. And every time I clicked on a link in Emacs, a new outlook-process was started. So I sticked to the great solution by user259... – Keks Dose – 2012-01-26T13:56:55.147

This is fantastic ! Thank you for providing this solution. I tried it with outlook 2007 with the registry tweak and it worked like a charm ! I found 1 issue if I ran the macro when I had a meeting invite / appointment selected. The code threw an exception. Since I use it only on the inbox I solved this by Dim objMail as Object instead of MailItem - however this may not be the right solution since the code could still fail if the item selected doesn't have Subject/ SenderName members. The code could probably check if the selected item is of proper type and provide a MsgBox if it is not. – koushik – 2012-02-22T15:23:52.383

1

I "scratched this itch" of mine a bit more as I had to record links to some appointments for working on related items (so I can refer ot info / attachments therein or reply all when I have updates etc). Now this can export mails, calendar items, contacts, notes, journal entries and at least will not fail when invoked on other entries. The modified code is at http://pastebin.com/gNWLVNRk (I can provide a diff if it would help - though I don't know how to make on in VBA). I didn't have to make any other change (emacs-side or regsitry) for this to work on my end. HTH.

– koushik – 2012-07-23T13:50:30.927

@koushik: Thank you for your great script. Where do you past those links? The syntax [[url][description]] is not recognized by outlook... – Simon – 2013-08-01T12:54:24.303

6

I solved this by writing a simple vbscript (download):

Set Outlook = CreateObject("Outlook.Application")
Set SelectedItem = Outlook.ActiveExplorer.Selection.Item(1)
Set Shell = CreateObject("Shell.Application")
Shell.ShellExecute "cmd", "/c echo Outlook:" & SelectedItem.entryID & " | clip", "", "runas", 1

It copies a link of the element (Email, Calendar entry, ...) you have currently selected in Outlook to your clipboard:

Outlook:176CZREX7A79L9TG1T0AJ6HQ8DEBLTFS60HUQYKT2IXBBZ9ZZVA73MNRYVRWRL4RY0VCPQE1IB5GAWY0D8OSMOB4IFDV5OMG9NX2BBKGFA3IWSD62UCNVK0HD9GA80BIDZSBCZL7INCT

You can even use a redirection service so that you get a HTTP link (because Outlook: links are probably not detected automatically if you paste is somewhere, but HTTP links are) (download), just replace the last line with:

Shell.ShellExecute "cmd", "/c echo https://api.fnkr.net/goto/jsclient/raw/?closeAfter=500#Outlook:" & SelectedItem.entryID & " | clip", "", "runas", 1

Note that you need to make Outlook: links working first.
http://www.slipstick.com/problems/outlook-missing-outlook-protocol/ (scroll down to "Do It For Me")

Tested with Outlook 2010.

fnkr

Posted 2009-11-17T19:09:46.233

Reputation: 530

3

came across Linker applet.going to try it out..you may want to as well http://www.teamscope.com/otherpro/utilities.asp#linker

Here's the marketing drible..

Linker™ for Windows® creates hyperlinks to items and folders in Outlook, and to files and folders in Windows Explorer. It is a system tray applet places the hyperlink in the Windows clipboard. The hyperlink can then be pasted into any Microsoft Office document, web page, e-mail message, or any document that supports hyperlinks.

Greetings from sunny South Africa!

GIovanni Focaraccio

Posted 2009-11-17T19:09:46.233

Reputation:

Using Office Pro Plus 2016 + Win 10 Pro, and it did not work. It breaks when accessing the links that had been copied - so when clicking \<email address>\Drafts~test , the unknown app is pick up by win 10 so it breaks. – Nasri Najib – 2018-07-30T04:06:34.630

Linker works sometimes, other times not so much. Overall feels quite buggy in Win 7 + Outlook 2010 – Andy – 2014-01-15T19:00:12.463

1

I prefer to copy the Outlook Item content to the system clipboard and then yank it into an Org-mode note.

http://www.emacswiki.org/emacs/PlannerModeContrib#toc10

Raymond Zeitler

Posted 2009-11-17T19:09:46.233

Reputation: 11

1

I'm not sure about referencing a specific email but depending on your system you might be able to copy the email to the same location as the todo item. Just drag/drop the mail to a folder or the desktop and it will create a copy of the mail that you can treat as a normal file.

If you would be using .doc or more "advanced" files than .txt you could then link to this Outlook message file.

Paxxi

Posted 2009-11-17T19:09:46.233

Reputation: 6 952

1I'll go with that solution. Here's my new workflow: Drag the mail to a temporary folder. Create the todo item in org-mode. Add the message file as an attachment to the item: C-c C-a m (the message file is moved to the attachments folder). Later I can open the message from the todo item by pressing C-c C-a o. – Christian Berg – 2009-11-18T16:07:04.530

0

I use Wunderlist to manage my tasks and found that with the Wunderlist add-in for Outlook I can create new tasks directly from an email message and Wunderlist automatically creates a link in the task notes to the original message. A few things to keep in mind:

  1. I always move the message to a folder first because (last time I checked) the URL breaks if you later move the message to another folder.
  2. Even though there is an add-in for Outlook desktop, it doesn't seem to include the link, so I use Outlook on the Web when I want to create a task.
  3. I have only tried this with Outlook on the Web for Office 365 using a corporate email account. I assume it works equally well with consumer Office 365 accounts, but haven't tried it.
  4. Even if you don't use Wunderlist, you could sign-up and use it to generate the URL when you need it.

And just for disclosure, I do work for Microsoft, though I'm not associated with either the Outlook or Wunderlist teams.

AJSkew

Posted 2009-11-17T19:09:46.233

Reputation: 19

1Please read the question again carefully. Your answer does not answer the original question. OP is using emacs. – DavidPostill – 2016-09-14T21:53:54.427

1@DavidPostill Respectfully, I thought I did. That's why I included #4 as a way to obtain a URL to a message that can then be stored anywhere, including in a text file. – AJSkew – 2016-09-14T23:31:15.397

0

I don't have sufficient reputation credits to put in a comment to the accepted answer above, but I wanted to put a cross-reference in for a revision to the excellent answer provided by @user25995 - which I posted at (emacs) StackExchange.

Based on a comment I received to a question I posted there, I changed the use of (deprecated) org-add-link-type to org-link-set-parameters and included an export: function so that the HTML export backend gave me a properly formatted <a href="outlook:..."> link type.

kwoodham

Posted 2009-11-17T19:09:46.233

Reputation: 11

Commentary shouldn't be submitted as an answer because of your inability to submit an actual comment. – Ramhound – 2017-10-04T15:53:56.357

2@Ramhound - I took pains to point to the accepted answer, even by providing a link and acknowledging the author. I then offered a small revision that avoids the use of a function that is now deprecated. I did not intend to breach protocol here - is there a correct way to communicate this if I don't have enough Brownie points to comment on the accepted answer? – kwoodham – 2017-10-04T18:22:07.117

0

Not without some kind of custom code. The Outlook URI's can get you to the containing folder within Outlook, but that's about it. You would need to come up with a clever filing strategy that aligned with your linking strategy to get more granular.

squillman

Posted 2009-11-17T19:09:46.233

Reputation: 5 676

1Other answers show it's possible, hence the downvote. – Saaru Lindestøkke – 2019-08-22T23:40:33.933

0

Probably your requirement is different with mine.

Outook 2013 > Message Tab(your normal view) > 'Actions' Button > View in Browser

Then I get that link from the browser.

Hope that help

Frank

Posted 2009-11-17T19:09:46.233

Reputation: 1

2This seemed promising but in Outlook 2013 for me this creates a .mht file in AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\ and opens that in IE using a 'mhtml:file://..` url so no go. – Miserable Variable – 2015-01-05T17:30:49.467

0

You can copy an Outlook e-mail to OneNote (comes in as a yellow letter icon), then right click and select 'link to paragraph', and then paste the link into another document that can work with links.

But anyway, Microsoft should have made this whole thing of linking to an e-mail a standard feature. It was such a useful feature of Lotus Notes.

Umiboshi

Posted 2009-11-17T19:09:46.233

Reputation: 11

It's a useful feature. But, what's the security model? Do you want a bad guy to send you a link in an email that you might open by accident? GUIDs, sure, not visible outside - unless they leak... – Krazy Glew – 2019-04-09T04:34:18.440