PstFolder Class
A folder of an Outlook data file: its subfolders, its items and its associated (hidden) items.
public sealed class PstFolderExample
using var file = PstFile.Open(path);
var subjects = new List<string>();
void Visit(PstFolder folder)
{
foreach (var item in folder.EnumerateItems())
{
subjects.Add($"{folder.Path}: {item.Subject}");
}
foreach (var child in folder.Folders)
{
Visit(child);
}
}
Visit(file.RootFolder);
Assert.Contains("Top of Outlook data file/Inbox/tmp: original email", subjects);Properties
| Name | Description |
|---|---|
| ContainerClass | Gets the class of the items the folder contains, such as IPF.Note (mail), IPF.Contact, IPF.Appointment or IPF.Task. |
| ContentCount | Gets the number of items, as stored in the folder. |
| DisplayName | Gets the display name of the folder. |
| Folders | Gets the subfolders. |
| HasSubfolders | Gets whether the folder has subfolders, as stored in the folder. |
| IsSearchFolder | Gets whether the folder is a search folder, whose items are the results of a search in other folders. |
| NodeId | Gets the identifier of the node of the folder in the file. |
| Parent | Gets the parent folder, or null for the root folder. |
| Path | Gets the path of the folder: the display names of the folders from the root folder (excluded), separated by /. |
| Properties | Gets the properties of the folder. |
| UnreadCount | Gets the number of unread items, as stored in the folder. |
ContainerClass
PstFolder.csContentCount
PstFolder.csDisplayName
PstFolder.csFolders
PstFolder.csGets the subfolders.
public IReadOnlyList<PstFolder> Folders { get; }HasSubfolders
PstFolder.csIsSearchFolder
PstFolder.csNodeId
PstFolder.csParent
PstFolder.csPath
PstFolder.csProperties
PstFolder.csUnreadCount
PstFolder.csMethods
| Name | Description |
|---|---|
| EnumerateAssociatedItems() | Enumerates the associated items of the folder: the hidden items that store views, rules or settings. |
| EnumerateItems() | Enumerates the items of the folder (messages, contacts, appointments...). Each item is read when the enumeration reaches it. A search folder has no items when Outlook stores its results in a structure that [MS-PST] does not document. |
| GetFolder(string) | Returns a subfolder from its display name, ignoring case. |
| ToString() | Returns the display name of the folder. |
EnumerateAssociatedItems()
PstFolder.csEnumerates the associated items of the folder: the hidden items that store views, rules or settings.
public IEnumerable<MapiMessage> EnumerateAssociatedItems()Returns
IEnumerable<MapiMessage> The associated items.
Exceptions
InvalidEmailDataException- The associated contents table of the folder or an item is malformed.
EnumerateItems()
PstFolder.csEnumerates the items of the folder (messages, contacts, appointments...). Each item is read when the enumeration reaches it. A search folder has no items when Outlook stores its results in a structure that [MS-PST] does not document.
public IEnumerable<MapiMessage> EnumerateItems()Returns
IEnumerable<MapiMessage> The items, as MapiMessage or one of its derived classes for the items Outlook types (MapiContact, MapiAppointment, MapiTask, MapiDistributionList).
Exceptions
InvalidEmailDataException- The contents table of the folder or an item is malformed.
GetFolder(string)
PstFolder.csReturns a subfolder from its display name, ignoring case.
Parameters
namestring- The display name of the subfolder.
Returns
PstFolder? The subfolder, or null when the folder has no subfolder with this name.