Microsoft Access Office VB VBA Help and Examples
           

Outlook - Setting a reference to an Exchange Public Folder

If you have a public folder or personal folder that you want to process in code then the following will show you how to do it. The key to this is finding out what the folders unique EntryID is. This unique id can be used to set a reference to a folder without having to go through loads of nested folders to get there.

Paste the following VBA code into a new module.

Private Sub GetOutlookFolderID()
   Dim olfolder As Outlook.MAPIFolder
   Dim olapp As Outlook.Application
   Set olapp = CreateObject("Outlook.Application")
   Set olfolder = olapp.GetNamespace("MAPI").PickFolder
   olfolder.Display
   Debug.Print olfolder.EntryID
   Set olfolder = Nothing
   Set olapp = Nothing 
End Sub

Private Sub GetFolderFromID() 
   Dim olfolder As Outlook.MAPIFolder
   Dim olapp As Outlook.Application
   Set olapp = CreateObject("Outlook.Application")
   Set olfolder = olapp.GetNamespace("Mapi").GetFolderFromID("InsertEntryIDHere")
   olfolder.Display
   Set olfolder = Nothing 
   Set olapp = Nothing
End Sub

Run the GetOutlookFolderID sub which will open an outlook session and pop up a choose folder dialog box. Browse to the folder in question and double click it. This will then display that folder in a new window (check it's opened the correct one) and send the entry ID to the debug window.

Go to the debug window and copy the extremely long EntryID string and replace the text in the second sub where it says InsertEntryIDHere with the text from the debug window.

Run the second sub which should pop up the same window.

Points to note. Some entryID's are changed when folders are moved about.

 
HOME   SEARCH SITE   PRIVACY POLICY   CONTACT
The code and application content of this site is copyright of Smiley I.T. and as such reproduction in any form which is for commercial use requires the permission of the Webmaster. Any use of this code for non-commercial use only requires a link or comment back to the original page you took the code from.