This VBA macro code is heavily inspired by the information available at I only adjusted the generated link text to make it suitable for use in WikidPad.

Just create these macros in Outlook, and optionally bind the macro to a toolbar button or menu command for easy access.

In Outlook, select one or more messages and execute the macro (using the toolbar button, for example). Your clipboard will now contain direct URL links to these messages in a WikidPad-ready format, ready to be pasted in your wiki page. By default, the link shows the message subject, author and received date & time. This can be adjusted in the GetMsgDetails?() function if needed.


For Outlook 2007, these links won't work out-of-the-box. That's because Outlook 2007 does not register the "outlook://" protocol handler in Windows. You can configure this yourself using RegEdit?, a detailed explanation is available over here: Outlook links in WikidPad should work without problems afterwards.

The code

Sub CopyItemIDs()
    Dim myOLApp As Application
    Dim myNameSpace As NameSpace
    Dim currentMessage As MailItem
    Dim ClipBoard As String
    Dim DataO As DataObject
    ' Housekeeping: set up the macro environment
    Set myOLApp = CreateObject("Outlook.Application")
    Set myNameSpace = myOLApp.GetNamespace("MAPI")
    ' Figure out if the active window is a list of messages or one message
    ' in its own window
    On Error GoTo QuitIfError    ' But if there's a problem, skip it
    Select Case myOLApp.ActiveWindow.Class
        ' The active window is a list of messages (folder); this means there
        ' might be several selected messages
        Case olExplorer
            ' build the clipboard string
            For Each currentMessage In myOLApp.ActiveExplorer.Selection
                ClipBoard = GetMsgDetails(currentMessage, ClipBoard)
        ' The active window is a message window, meaning there will only
        ' be one selected message (the one in this window)
        Case olInspector
            ' build the clipboard string
            ClipBoard = GetMsgDetails(myOLApp.ActiveInspector.CurrentItem, _
        ' can't handle any other kind of window; anything else will be ignored
    End Select
QuitIfError:       ' Come here if there was some kind of problem
    Set myOLApp = Nothing
    Set myNameSpace = Nothing
    Set currentMessage = Nothing

    Set DataO = New DataObject
    DataO.SetText ClipBoard
    Set DataO = Nothing
End Sub
Function GetMsgDetails(Item As MailItem, Details As String) As String

    If Details <> "" Then
        Details = Details + vbCrLf
    End If
    Details = Details + "[Outlook:" + Item.EntryID + " | " + Item.Subject + " (" + Item.SenderName + ", " + Format(Item.ReceivedTime, "yyyymmdd | hh:mm") + ")]" + vbCrLf
    GetMsgDetails = Details

End Function

Last modified 10 years ago Last modified on Jul 7, 2010 1:31:53 PM