GetFolderFromID Method

Microsoft Outlook Visual Basic

GetFolderFromID Method

       

Returns a MAPIFolder object identified by the specified entry ID (if valid). This method is used for ease of transition between MAPI and OLE/Messaging applications and Microsoft Outlook.

expression.GetFolderFromID(EntryIDFolder, EntryIDStore)

expression   Required. An expression that returns a NameSpace object.

EntryIDFolder   Required String. The EntryID of the folder.

EntryIDStore   Optional Variant. The StoreID for the folder.

Example

This Visual Basic for Applications example obtains the EntryID and StoreID for a subfolder within the Tasks Folders collection and then calls the GetFolderFromID method using these values to obtain the same subfolder. The folder is then displayed.

Set myolapp = CreateObject("Outlook.Application")
Set myNameSpace = myolapp.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderTasks)
myEntryID = myFolder.EntryID
myStoreID = myFolder.StoreID
Set myFolder = myNameSpace.GetFolderFromID(myEntryID, myStoreID)
myFolder.Display

If you use VBScript, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(13)
myEntryID = myFolder.EntryID
myStoreID = myFolder.StoreID
Set myNewFolder = myNameSpace.GetFolderFromID(myEntryID, myStoreID)
myNewFolder.Display