0
# Message Actions
1
2
Message action handling including flagging, coloring, and custom action decision workflows. This module provides functionality for performing actions on messages within the Mail application.
3
4
## Capabilities
5
6
### MEMessageAction
7
8
Represents actions that can be performed on messages including flagging and coloring. This is the primary class for working with message actions.
9
10
```python { .api }
11
class MEMessageAction:
12
"""
13
Represents an action that can be performed on a message.
14
15
Note: This class cannot be instantiated directly using init() or new().
16
Instances are created by the Mail framework based on user actions.
17
"""
18
```
19
20
### MEMessageActionDecision
21
22
Represents decisions for message actions. Used to communicate action decisions back to the Mail framework.
23
24
```python { .api }
25
class MEMessageActionDecision:
26
"""
27
Represents a decision about a message action.
28
29
Note: This class cannot be instantiated directly using init() or new().
30
Instances are provided by the Mail framework.
31
"""
32
```
33
34
## Message Action Flags
35
36
Constants representing different message flag types:
37
38
```python { .api }
39
MEMessageActionFlagNone: int # = 0, No flag
40
MEMessageActionFlagDefaultColor: int # = 1, Default color flag
41
MEMessageActionFlagRed: int # = 2, Red flag
42
MEMessageActionFlagOrange: int # = 3, Orange flag
43
MEMessageActionFlagYellow: int # = 4, Yellow flag
44
MEMessageActionFlagGreen: int # = 5, Green flag
45
MEMessageActionFlagBlue: int # = 6, Blue flag
46
MEMessageActionFlagPurple: int # = 7, Purple flag
47
MEMessageActionFlagGray: int # = 8, Gray flag
48
```
49
50
## Message Action Colors
51
52
Constants representing different message color options:
53
54
```python { .api }
55
MEMessageActionMessageColorNone: int # = 0, No color
56
MEMessageActionMessageColorGreen: int # = 1, Green color
57
MEMessageActionMessageColorYellow: int # = 2, Yellow color
58
MEMessageActionMessageColorOrange: int # = 3, Orange color
59
MEMessageActionMessageColorRed: int # = 4, Red color
60
MEMessageActionMessageColorPurple: int # = 5, Purple color
61
MEMessageActionMessageColorBlue: int # = 6, Blue color
62
MEMessageActionMessageColorGray: int # = 7, Gray color
63
```
64
65
## Enum Types
66
67
Type definitions for message action enums:
68
69
```python { .api }
70
MEMessageActionFlag: type # Enum type for message action flags
71
MEMessageActionMessageColor: type # Enum type for message action colors
72
```
73
74
## Usage Examples
75
76
### Working with Message Flags
77
78
```python
79
import MailKit
80
81
# Check message flag type
82
def handle_message_flag(flag_value):
83
if flag_value == MailKit.MEMessageActionFlagRed:
84
print("Message has red flag - high priority")
85
elif flag_value == MailKit.MEMessageActionFlagYellow:
86
print("Message has yellow flag - medium priority")
87
elif flag_value == MailKit.MEMessageActionFlagGreen:
88
print("Message has green flag - low priority")
89
elif flag_value == MailKit.MEMessageActionFlagBlue:
90
print("Message has blue flag - informational")
91
elif flag_value == MailKit.MEMessageActionFlagNone:
92
print("Message has no flag")
93
else:
94
print(f"Message has flag: {flag_value}")
95
96
# Example usage
97
handle_message_flag(MailKit.MEMessageActionFlagRed)
98
```
99
100
### Working with Message Colors
101
102
```python
103
import MailKit
104
105
# Set message color based on content analysis
106
def determine_message_color(message_content):
107
if "urgent" in message_content.lower():
108
return MailKit.MEMessageActionMessageColorRed
109
elif "important" in message_content.lower():
110
return MailKit.MEMessageActionMessageColorOrange
111
elif "fyi" in message_content.lower():
112
return MailKit.MEMessageActionMessageColorBlue
113
else:
114
return MailKit.MEMessageActionMessageColorNone
115
116
# Example usage
117
message_text = "This is an urgent request"
118
color = determine_message_color(message_text)
119
120
if color == MailKit.MEMessageActionMessageColorRed:
121
print("Setting message color to red for urgent content")
122
```
123
124
### Complete Flag and Color Reference
125
126
```python
127
import MailKit
128
129
# All available flags
130
message_flags = {
131
"none": MailKit.MEMessageActionFlagNone,
132
"default": MailKit.MEMessageActionFlagDefaultColor,
133
"red": MailKit.MEMessageActionFlagRed,
134
"orange": MailKit.MEMessageActionFlagOrange,
135
"yellow": MailKit.MEMessageActionFlagYellow,
136
"green": MailKit.MEMessageActionFlagGreen,
137
"blue": MailKit.MEMessageActionFlagBlue,
138
"purple": MailKit.MEMessageActionFlagPurple,
139
"gray": MailKit.MEMessageActionFlagGray
140
}
141
142
# All available colors
143
message_colors = {
144
"none": MailKit.MEMessageActionMessageColorNone,
145
"green": MailKit.MEMessageActionMessageColorGreen,
146
"yellow": MailKit.MEMessageActionMessageColorYellow,
147
"orange": MailKit.MEMessageActionMessageColorOrange,
148
"red": MailKit.MEMessageActionMessageColorRed,
149
"purple": MailKit.MEMessageActionMessageColorPurple,
150
"blue": MailKit.MEMessageActionMessageColorBlue,
151
"gray": MailKit.MEMessageActionMessageColorGray
152
}
153
154
# Function to get flag name from value
155
def get_flag_name(flag_value):
156
for name, value in message_flags.items():
157
if value == flag_value:
158
return name
159
return "unknown"
160
161
# Function to get color name from value
162
def get_color_name(color_value):
163
for name, value in message_colors.items():
164
if value == color_value:
165
return name
166
return "unknown"
167
168
# Example usage
169
flag_name = get_flag_name(MailKit.MEMessageActionFlagRed)
170
color_name = get_color_name(MailKit.MEMessageActionMessageColorBlue)
171
print(f"Flag: {flag_name}, Color: {color_name}")
172
```
173
174
### Working with Enum Types
175
176
```python
177
import MailKit
178
179
# Check if a value is a valid message action flag
180
def is_valid_message_flag(value):
181
valid_flags = [
182
MailKit.MEMessageActionFlagNone,
183
MailKit.MEMessageActionFlagDefaultColor,
184
MailKit.MEMessageActionFlagRed,
185
MailKit.MEMessageActionFlagOrange,
186
MailKit.MEMessageActionFlagYellow,
187
MailKit.MEMessageActionFlagGreen,
188
MailKit.MEMessageActionFlagBlue,
189
MailKit.MEMessageActionFlagPurple,
190
MailKit.MEMessageActionFlagGray
191
]
192
return value in valid_flags
193
194
# Check if a value is a valid message color
195
def is_valid_message_color(value):
196
valid_colors = [
197
MailKit.MEMessageActionMessageColorNone,
198
MailKit.MEMessageActionMessageColorGreen,
199
MailKit.MEMessageActionMessageColorYellow,
200
MailKit.MEMessageActionMessageColorOrange,
201
MailKit.MEMessageActionMessageColorRed,
202
MailKit.MEMessageActionMessageColorPurple,
203
MailKit.MEMessageActionMessageColorBlue,
204
MailKit.MEMessageActionMessageColorGray
205
]
206
return value in valid_colors
207
208
# Example usage
209
if is_valid_message_flag(MailKit.MEMessageActionFlagRed):
210
print("Red flag is valid")
211
212
if is_valid_message_color(MailKit.MEMessageActionMessageColorBlue):
213
print("Blue color is valid")
214
```