New-MapiFolder

Description

This cmdlet creates a new folder in a message store.

Syntax
Note: Parameters in orange are optional.
New-MapiFolder
-ParentFolderMapiObject<Mapi.NET.Folder>
-FolderNameString
-ContainerClassString
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags
New-MapiFolder
-StoreMapiObject<Mapi.NET.Store>
-FolderIDMapiObject<Mapi.NET.EntryID>
-FolderNameString
-ContainerClassString
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags
New-MapiFolder
-StoreMapiObject<Mapi.NET.Store>
-FolderPathString
-PathDelimiterString
-ContainerClassString
-OpenFlagsMapi.NET.Flags.ContainerOpenEntryFlags
Parameters
ParentFolderA Mapi.NET.Folder object that represents parent folder under which to create the new folder.
StoreA Mapi.NET.Store object that is used with either the FolderPath or FolderID parameters.
FolderName A text string for the new folder name when used with ParentFolder or Store and FolderID.
FolderPathA text string that is the full path for the new folder to be created. Used with the Store parameter. See remarks.
FolderIDA Mapi.NET.EntryID value that represents the parent folder under which to create FolderName.
OpenFlagsAn optional value from the Mapi.NET.Flags.ContainerOpenEntryFlags enumeration:
  • BestAccess
  • DontThrowIfEntryIsMissing
  • Modify
  • None
  • ShowSoftDeletes
PathDelimiterAn optional character or text string that identifies the separator between folders in FolderPath. Default when not used is '/'.
ContainerClassAn option text string that is used to declare the folder type. Common folder types are:
  • IPF.Note
  • IPF.Appointment
  • IPF.Contact
  • IPF.Post
Remarks

This cmdlet creates a new folder in a message store.

When using the ParentFolder parameter, this cmdlet simply creates a new folder as an immediate child of that folder.  No sub-path is allowed.  If a sub-path is used, a folder will be created with the path delimiters in the name.

Folders in a message store have a text value that describes the intended use of the folder, as a calendar folder for example.  The default value for the ContainerClass parameter is IPF.Note, which creates a regular mail folder type.  IPF.Post is commonly found on Public Folders.  There may be other folder types available, especially if 3rd party add-ins are used in Outlook.  The Container Class of a folder can be changed after it is created by using the Set-MapiProp cmdlet, if necessary.

When using the Store parameter, the FolderPath parameter indicates the full path to be created.  Any folders found non-existent as the path is examined are also created.  All folders created will be created with the ContainerClass provided (or the default if the ContainerClass parameter is omitted).

When using the Store and FolderID parameters together, only the FolderName parameter is used.  No sub-paths are used in the combination and if FolderName contains path separators, those become part of the folder name.

The optional OpenFlags parameter is useful if, after creation, properties of the new folder need to be adjusted.  In such a case, using the 'Modify' flag will return the new folder in a modifiable state.  OpenFlags, when omitted, defaults to 'BestAccess' which generally means read-only.

The PathDelimiter parameter is used to specify the character or string that FolderPath uses to distinguish individual folders.  The default value, when omitted, is '/'.  In any case, if a folder name in the folder path contains the delimiter, that character or string in the folder name needs to be doubled in order to not confuse the cmdlet as a separator.  For example, if a folder in a path is named 'Good/Bad', it should be written in the FolderPath argument as 'Good//Bad'.  The cmdlet will replace the duplicate delimiter internally.