or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

compose-sessions.mdextension-management.mdindex.mdmessage-actions.mdmessage-classes.mdprotocols-handlers.mdsecurity-encryption.md

message-classes.mddocs/

0

# Message Classes

1

2

Core classes for representing and manipulating mail messages, including message state, encryption information, and decoded message handling. These classes form the foundation for working with mail messages in MailKit extensions.

3

4

## Capabilities

5

6

### MEMessage

7

8

Represents a mail message with state and encryption information. This is the primary class for working with mail messages in the MailKit framework.

9

10

```python { .api }

11

class MEMessage:

12

"""

13

Represents a mail message.

14

15

Note: This class cannot be instantiated directly using init() or new().

16

Instances are provided by the Mail framework.

17

"""

18

```

19

20

### MEDecodedMessage

21

22

Represents a decoded message with security information and optional banner. Used for displaying processed messages with security context.

23

24

```python { .api }

25

class MEDecodedMessage:

26

def initWithData_securityInformation_context_(

27

self,

28

data, # NSData: Message data

29

securityInformation, # MEMessageSecurityInformation: Security info

30

context # Any: Message context

31

):

32

"""

33

Initialize a decoded message with data, security information, and context.

34

35

Args:

36

data: The message data

37

securityInformation: Security information for the message

38

context: Additional context for the message

39

40

Returns:

41

MEDecodedMessage: Initialized decoded message

42

"""

43

44

def initWithData_securityInformation_context_banner_(

45

self,

46

data, # NSData: Message data

47

securityInformation, # MEMessageSecurityInformation: Security info

48

context, # Any: Message context

49

banner # MEDecodedMessageBanner: Optional banner

50

):

51

"""

52

Initialize a decoded message with data, security information, context, and banner.

53

54

Args:

55

data: The message data

56

securityInformation: Security information for the message

57

context: Additional context for the message

58

banner: Optional banner for the decoded message

59

60

Returns:

61

MEDecodedMessage: Initialized decoded message

62

"""

63

```

64

65

### MEDecodedMessageBanner

66

67

Banner component for decoded messages with action capabilities. Provides UI elements for message banners with primary actions and dismissal options.

68

69

```python { .api }

70

class MEDecodedMessageBanner:

71

def initWithTitle_primaryActionTitle_dismissable_(

72

self,

73

title: str, # Banner title

74

primaryActionTitle: str, # Primary action button title

75

dismissable: bool # Whether banner can be dismissed

76

):

77

"""

78

Initialize a decoded message banner.

79

80

Args:

81

title: The title text for the banner

82

primaryActionTitle: The text for the primary action button

83

dismissable: Whether the banner can be dismissed by the user

84

85

Returns:

86

MEDecodedMessageBanner: Initialized banner

87

"""

88

89

def isDismissable(self) -> bool:

90

"""

91

Check if the banner can be dismissed.

92

93

Returns:

94

bool: True if the banner can be dismissed

95

"""

96

```

97

98

### MEEmailAddress

99

100

Handles email address representation and validation. Provides functionality for working with email addresses in the Mail framework.

101

102

```python { .api }

103

class MEEmailAddress:

104

def initWithRawString_(self, rawString: str):

105

"""

106

Initialize an email address from a raw string.

107

108

Args:

109

rawString: The email address string

110

111

Returns:

112

MEEmailAddress: Initialized email address

113

"""

114

```

115

116

### MEMessageEncodingResult

117

118

Represents the result of message encoding operations. Contains information about the success or failure of encoding operations.

119

120

```python { .api }

121

class MEMessageEncodingResult:

122

"""

123

Represents the result of a message encoding operation.

124

125

Note: This class cannot be instantiated directly using init() or new().

126

Instances are provided by the Mail framework during encoding operations.

127

"""

128

```

129

130

## Message States

131

132

Constants representing different message states:

133

134

```python { .api }

135

MEMessageStateReceived: int # = 0, Message has been received

136

MEMessageStateDraft: int # = 1, Message is a draft

137

MEMessageStateSending: int # = 2, Message is being sent

138

```

139

140

## Encryption States

141

142

Constants representing message encryption states:

143

144

```python { .api }

145

MEMessageEncryptionStateUnknown: int # = 0, Encryption state unknown

146

MEMessageEncryptionStateNotEncrypted: int # = 1, Message is not encrypted

147

MEMessageEncryptionStateEncrypted: int # = 2, Message is encrypted

148

```

149

150

## Usage Examples

151

152

### Creating a Decoded Message

153

154

```python

155

import MailKit

156

157

# Create security information

158

security_info = MailKit.MEMessageSecurityInformation.alloc().initWithSigners_isEncrypted_signingError_encryptionError_(

159

signers=[],

160

isEncrypted=True,

161

signingError=None,

162

encryptionError=None

163

)

164

165

# Create decoded message

166

decoded_message = MailKit.MEDecodedMessage.alloc().initWithData_securityInformation_context_(

167

data=message_data,

168

securityInformation=security_info,

169

context=message_context

170

)

171

```

172

173

### Creating a Message Banner

174

175

```python

176

import MailKit

177

178

# Create a dismissable banner with primary action

179

banner = MailKit.MEDecodedMessageBanner.alloc().initWithTitle_primaryActionTitle_dismissable_(

180

title="Security Warning",

181

primaryActionTitle="View Details",

182

dismissable=True

183

)

184

185

# Check if banner is dismissable

186

if banner.isDismissable():

187

print("Banner can be dismissed by user")

188

```

189

190

### Working with Email Addresses

191

192

```python

193

import MailKit

194

195

# Create email address from string

196

email = MailKit.MEEmailAddress.alloc().initWithRawString_("user@example.com")

197

```

198

199

### Checking Message States

200

201

```python

202

import MailKit

203

204

# Check message state

205

if message_state == MailKit.MEMessageStateReceived:

206

print("Message has been received")

207

elif message_state == MailKit.MEMessageStateDraft:

208

print("Message is a draft")

209

elif message_state == MailKit.MEMessageStateSending:

210

print("Message is being sent")

211

212

# Check encryption state

213

if encryption_state == MailKit.MEMessageEncryptionStateEncrypted:

214

print("Message is encrypted")

215

elif encryption_state == MailKit.MEMessageEncryptionStateNotEncrypted:

216

print("Message is not encrypted")

217

else:

218

print("Encryption state unknown")

219

```