HOWTO: VB/OOM - Display a message using Store ID and item ID

How to display a message in an outlook window using the store id and item id using OOM. CDO 1.21 cannot just display a message without having it being in a state of forward, reply, etc - so OOM is a better solution.

'TODO - set a reference to the outlook object model
' Call DisplayMessage, passing the store ID and the sMessageID properties.
'
Private Sub DisplayMessage(sStoreID As String, sMessageID As String)
' Create Outlook application.

Dim oApp As Outlook.Application
Set oApp = New Outlook.Application

' Get Mapi NameSpace.
Dim oNS As Outlook.NameSpace
Set oNS = oApp.GetNamespace("mapi")
oNS.Logon "Outlook", , False, True
Dim oMsg As MailItem

Set oMsg = oNS.GetItemFromID(sMessageID, sStoreID)
oMsg.Display ' modal setting available

' Log off.
oNS.Logoff

' Clean up.
Set oApp = Nothing
Set oNS = Nothing
Set oItems = Nothing
Set oMsg = Nothing
End Sub