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

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?


Solution 1:

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.

Solution 2:

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.

Solution 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!

Solution 4:

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.