0
# Tasks
1
2
Task management functionality for creating, updating, and tracking tasks and to-do items with support for due dates, priorities, and completion status.
3
4
## Capabilities
5
6
### Task Management
7
8
```python { .api }
9
class Task:
10
def __init__(self, account: Account = None, folder: Folder = None, **kwargs):
11
"""Create a new task."""
12
13
# Basic properties
14
subject: str
15
body: Body | HTMLBody
16
status: str # 'NotStarted', 'InProgress', 'Completed', 'WaitingOnOthers', 'Deferred'
17
percent_complete: int
18
19
# Dates
20
start_date: EWSDate
21
due_date: EWSDate
22
complete_date: EWSDate
23
24
# Assignment
25
owner: str
26
delegator: str
27
assigned_time: EWSDateTime
28
29
# Priority and importance
30
importance: str # 'Low', 'Normal', 'High'
31
32
# Recurrence
33
recurrence: Recurrence
34
is_recurring: bool
35
36
# Progress tracking
37
actual_work: int # Minutes
38
total_work: int # Minutes
39
40
# Categories
41
categories: list[str]
42
43
def save(self, update_fields: list = None):
44
"""Save the task."""
45
46
def delete(self, delete_type: str = 'MoveToDeletedItems'):
47
"""Delete the task."""
48
49
def mark_complete(self):
50
"""Mark the task as completed."""
51
52
def assign(self, assignee: Mailbox):
53
"""Assign the task to someone."""
54
```
55
56
Usage example:
57
58
```python
59
from exchangelib import Task, EWSDate
60
from datetime import date, timedelta
61
62
task = Task(
63
account=account,
64
folder=account.tasks,
65
subject='Complete project documentation',
66
body=Body('Write comprehensive documentation for the new feature.'),
67
status='NotStarted',
68
importance='High',
69
due_date=EWSDate.from_date(date.today() + timedelta(days=7)),
70
percent_complete=0
71
)
72
73
task.save()
74
75
# Later, update progress
76
task.percent_complete = 50
77
task.status = 'InProgress'
78
task.save()
79
80
# Mark as complete
81
task.mark_complete()
82
```