Folder¶
The Folder type represents a folder in a PST file.
Properties¶
ID¶
Returns the folder's node ID.
Name¶
Returns the display name of the folder.
ContentCount¶
Returns the number of messages in the folder.
UnreadCount¶
Returns the number of unread messages.
HasSubfolders¶
Returns true if the folder has subfolders.
ContainerClass¶
Returns the folder's container class (e.g., "IPF.Note", "IPF.Appointment").
Subfolder Navigation¶
Subfolders¶
Returns an iterator over subfolders.
for subfolder, err := range folder.Subfolders() {
if err != nil {
log.Printf("Error: %v", err)
continue
}
name, _ := subfolder.Name()
fmt.Printf("Subfolder: %s\n", name)
}
SubfolderCount¶
Returns the number of subfolders.
FindSubfolder¶
Finds a subfolder by name.
inbox, err := folder.FindSubfolder("Inbox")
if err != nil {
if errors.Is(err, outlookpst.ErrNotFound) {
fmt.Println("Not found")
}
}
Message Access¶
Messages¶
Returns an iterator over messages in the folder.
for msg, err := range folder.Messages() {
if err != nil {
continue
}
subject, _ := msg.Subject()
fmt.Printf("Message: %s\n", subject)
}
MessageCount¶
Returns the number of messages in the folder.
Search Folders¶
IsSearchFolder¶
Returns true if this is a search folder. Search folders are virtual folders whose contents are determined by search criteria.
AsSearchFolder¶
Converts to a SearchFolder if this is a search folder. Returns nil if this is not a search folder.
if folder.IsSearchFolder() {
sf := folder.AsSearchFolder()
criteria, _ := sf.SearchCriteria()
fmt.Printf("Recursive: %v\n", criteria.IsRecursive())
}
Advanced Access¶
PropertyBag¶
Returns the folder's property bag for advanced property access.
bag := folder.PropertyBag()
for _, propID := range bag.Properties() {
fmt.Printf("Property: 0x%04X\n", propID)
}
HierarchyTable¶
Returns the hierarchy table (subfolders) for advanced access.
ContentsTable¶
Returns the contents table (messages) for advanced access.
Example¶
func printFolderInfo(folder *outlookpst.Folder, indent string) {
name, _ := folder.Name()
contentCount, _ := folder.ContentCount()
unreadCount, _ := folder.UnreadCount()
containerClass, _ := folder.ContainerClass()
fmt.Printf("%s[%s]\n", indent, name)
fmt.Printf("%s Type: %s\n", indent, containerClass)
fmt.Printf("%s Items: %d (%d unread)\n", indent, contentCount, unreadCount)
// Recurse into subfolders
for subfolder, err := range folder.Subfolders() {
if err != nil {
continue
}
printFolderInfo(subfolder, indent+" ")
}
}