Get-MapiFolder

Description

This cmdlet retrieves an instance of a Mapi.NET.Folder object.

Syntax

Note: Parameters in orange are optional.

Get-MapiFolder
-SessionMapiObject<Mapi.NET.Session>
-FolderIDMapiObject<Mapi.NET.EntryID>
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags
 

Get-MapiFolder
-SessionMapiObject<Mapi.NET.Session>
-FolderPathString
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags
-PathDelimiterString

Get-MapiFolder
-SessionMapiObject<Mapi.NET.Session>
-CommonFolderPowerMapi.Commands.GetFolder.CommonFolders
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags

Get-MapiFolder
-StoreMapiObject<Mapi.NET.Store>
-FolderIDMapiObject<Mapi.NET.EntryID>
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags

Get-MapiFolder
-StoreMapiObject<Mapi.NET.Store>
-FolderPathString
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags
-PathDelimiterString

Get-MapiFolder
-StoreMapiObject<Mapi.NET.Store>
-CommonFolderPowerMapi.Commands.GetFolder.CommonFolders
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags

Get-MapiFolder
-ParentFolderMapiObject<Mapi.NET.Folder>
-FolderPathString
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags

 

 

Parameters
SessionA Mapi.NET.Session object from which the default store will be used to retrieve the folder represented by FolderPath or FolderID.
StoreA Mapi.NET.Store object that represents the message store in which FolderPath or FolderID reference.
ParentFolderA Mapi.NET.Folder object that is used to get all child folders, or a specific subfolder using FolderPath.
CommonFolderOne of the enumeration values from PowerMapi.Commands.GetFolder.CommonFolders used to retrieve a common, well-known folder.
Enumeration values are:
  • NotSpecified
  • Inbox
  • Drafts
  • SentItems
  • DeletedItems
  • Calendar
  • Contacts
  • Tasks
  • Notes
  • Journal
  • Outbox
  • IPMSubtree (the top of the visible tree, the parent of Inbox)
  • NonIPMSubtree
FolderPathA string that is a folder path for the folder to retrieve. When used with Session or Store, this must be a full path (see remarks).  When used with ParentFolder, it can be a relative or full path.
FolderIDA Mapi.NET.EntryID object representing the folder to retrieve.  This must be an EntryID relative to the Store parameter, or relative to the default store if used with the Session parameter.
OpenFlagsOne of the flag values from the Mapi.NET.Flags.ContainerOpenEntryFlags enumeration:
  • AllFlags
  • BestAccess (this is the default)
  • DeferredErrors
  • DontThrowIfEntryIsMissing
  • Modify
  • NoCache
  • None
PathDelimiterAn optional SwitchParameter, which when present defines the path delimiter used in the FolderPath parameter.  The default path delimiter is a '/' character.  If a folder has this string in its name, a double instance escapes the delimiter. For example, a folder's name is 'Good/Bad' and contains the path delimiter; in this case the '/' in the folder name should be doubled as such: 'Root/Parent/Good//Bad'
Remarks

This cmdlet retrieves one or more Mapi.NET.Folder objects.

When using the ParentFolder parameter, passing $null, and empty string, or omitting the FolderPath parameter will cause the cmdlet to return all the immediate children of ParentFolder.

When using the ParentFolder parameter, a relative path can be used to select a folder below it, either immediately or several levels down.  If a full folder path is provided, the cmdlet will access the underlying Store object of ParentFolder and will retrieve the folder as a full path.

When using the Session parameter, a query is made to determine the default Store and folder selection is then made from the context of the default store.  The Session parameter does not enumerate the stores to find the folder.  In most cases, the default store will be the mailbox that into which new email is delivered.  Starting with Outlook 2010, it is possible to have a session with multiple independent mailboxes, however, even in this case there will be a single store that is the "default".

Note that with MAPI there are Open Object Limits.  Attempting to open 100s of folders at concurrently will exceed these limits and the effect will be that no new folders can be opened until some others have been released.

A folder object can be released with the following pattern:  object.MapiObject.Dispose()