0
# Folders and Organization
1
2
Folder management for organizing and accessing Exchange folders, including standard folders (Inbox, Sent, Calendar) and custom folders. Supports folder creation, deletion, and hierarchical organization.
3
4
## Capabilities
5
6
### Folder Operations
7
8
```python { .api }
9
class Folder:
10
def __init__(self, account: Account = None, **kwargs):
11
"""Base folder class."""
12
13
# Properties
14
name: str
15
display_name: str
16
folder_class: str
17
total_count: int
18
child_folder_count: int
19
unread_count: int
20
21
# Hierarchy
22
parent_folder_id: FolderId
23
child_folders: list[Folder]
24
25
def create_folder(self, name: str, folder_class: str = None) -> Folder:
26
"""Create a child folder."""
27
28
def delete_folder(self, delete_type: str = 'HardDelete'):
29
"""Delete this folder."""
30
31
def get_folder(self, name: str) -> Folder:
32
"""Get a child folder by name."""
33
34
def move_folder(self, to_folder: Folder):
35
"""Move this folder to another parent."""
36
37
def copy_folder(self, to_folder: Folder):
38
"""Copy this folder to another parent."""
39
40
class FolderCollection:
41
def filter(self, *args, **kwargs):
42
"""Filter folders by criteria."""
43
44
def all(self):
45
"""Get all folders."""
46
47
def count(self):
48
"""Count folders."""
49
```
50
51
### Standard Folders
52
53
```python { .api }
54
# Standard folder types accessible via Account
55
class Account:
56
inbox: Folder
57
outbox: Folder
58
sent: Folder
59
drafts: Folder
60
deleted_items: Folder
61
calendar: Folder
62
contacts: Folder
63
tasks: Folder
64
notes: Folder
65
journal: Folder
66
junk_email: Folder
67
68
# Public folders
69
public_folders_root: Folder
70
71
# Archive folders
72
archive_inbox: Folder
73
archive_deleted_items: Folder
74
```
75
76
### Folder Traversal
77
78
```python { .api }
79
# Traversal depth constants
80
DEEP: str = 'Deep'
81
SHALLOW: str = 'Shallow'
82
83
def get_folders(self, depth: str = SHALLOW) -> list[Folder]:
84
"""Get child folders with specified depth."""
85
86
def walk(self) -> Generator[Folder]:
87
"""Walk through all folders recursively."""
88
```
89
90
Usage example:
91
92
```python
93
from exchangelib import DEEP, SHALLOW
94
95
# Create custom folder
96
custom_folder = account.inbox.create_folder('Important Projects')
97
98
# Get all folders
99
all_folders = account.inbox.get_folders(depth=DEEP)
100
101
# Find specific folder
102
project_folder = account.root.get_folder('Projects')
103
104
# Organize messages
105
for message in account.inbox.filter(subject__contains='Project'):
106
message.move(custom_folder)
107
```