Become a Columnist Microsoft Exchange Site Microsoft Support SiteMSDN Exchange Site

   

Subscribe to OutlookExchange
Anderson Patricio
Ann Mc Donough
Bob Spurzem
Brian Veal
Catherine Creary
Cherry Beado
Colin Janssen
Collins Timothy Mutesaria
Drew Nicholson
Fred Volking
Glen Scales
Goran Husman
Guy Thomas
Henrik Walther
Jason Sherry
Jayme Bowers
John Young
Joyce Tang
Justin Braun
Konstantin Zheludev
Kristina Waters
Kuang Zhang
Mahmoud Magdy
Martin Tuip
Michael Dong
Michele Deo
Mitch Tulloch
Nicolas Blank
Pavel Nagaev
Ragnar Harper
Ricardo Silva
Richard Wakeman
Russ Iuliano
Santhosh Hanumanthappa
Steve Bryant
Steve Craig
Todd Walker
Tracey J. Rosenblath
 
 

Find a folder by Name

'
' Function to walk a path to open an Outlook folder
'
' Dim flr As Outlook.MAPIFolder
' Set flr = OpenMAPIFolder("\Microsoft Mail Shared Folders\SharedFolder\Contacts")

'
' This routine does the following generically:
' Set ns = app.GetNamespace("MAPI")
' Set flr = ns.Folders("Microsoft Mail Shared Folders")
' Set flr = flr.Folders("Shared Folder")
' Set flr = flr.Folders("Contacts")
'

Function OpenMAPIFolder(ByVal szPath As String) As Outlook.MAPIFolder

Dim app As New Outlook.Application
Dim ns As Outlook.NameSpace
Dim flr As Outlook.MAPIFolder
Dim szDir As String
Dim i As Long

If Left(szPath, Len(Application.PathSeparator)) = Application.PathSeparator Then
szPath = Mid(szPath, Len(Application.PathSeparator) + 1)
Else
Set flr = app.ActiveExplorer.CurrentFolder
End If

While szPath <> ""
i = InStr(szPath, Application.PathSeparator)

If i Then
szDir = Left(szPath, i - 1)
szPath = Mid(szPath, i + Len(Application.PathSeparator))
Else
szDir = szPath
szPath = ""
End If

If flr Is Nothing Then
Set ns = app.GetNamespace("MAPI")
Set flr = ns.Folders(szDir)
Else
Set flr = flr.Folders(szDir)
End If

Wend

Set OpenMAPIFolder = flr
End Function

Once you have the folder, you could save the EntryID, and use that to reopen the folder...


Disclaimer: Your use of the information contained in these pages is at your sole risk. All information on these pages is provided "as is", without any warranty, whether express or implied, of its accuracy, completeness, fitness for a particular purpose, title or non-infringement, and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by Stephen Bryant or Pro Exchange. OutlookExchange.Com, Stephen Bryant and Pro Exchange shall not be liable for any damages you may sustain by using this information, whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.

Copyright Stephen Bryant 2008