Management of the process of sending, receiving, reading, and editing emails.
| 213 | |
| 214 | |
| 215 | class Message(ApiComponent, AttachableMixin, HandleRecipientsMixin): |
| 216 | """ Management of the process of sending, receiving, reading, and |
| 217 | editing emails. """ |
| 218 | |
| 219 | _endpoints = { |
| 220 | 'create_draft': '/messages', |
| 221 | 'create_draft_folder': '/mailFolders/{id}/messages', |
| 222 | 'send_mail': '/sendMail', |
| 223 | 'send_draft': '/messages/{id}/send', |
| 224 | 'get_message': '/messages/{id}', |
| 225 | 'move_message': '/messages/{id}/move', |
| 226 | 'copy_message': '/messages/{id}/copy', |
| 227 | 'create_reply': '/messages/{id}/createReply', |
| 228 | 'create_reply_all': '/messages/{id}/createReplyAll', |
| 229 | 'forward_message': '/messages/{id}/createForward', |
| 230 | 'get_mime': '/messages/{id}/$value', |
| 231 | } |
| 232 | |
| 233 | def __init__(self, *, parent=None, con=None, **kwargs): |
| 234 | """ Makes a new message wrapper for sending and receiving messages. |
| 235 | |
| 236 | :param parent: parent folder/account to create the message in |
| 237 | :type parent: mailbox.Folder or Account |
| 238 | :param Connection con: connection to use if no parent specified |
| 239 | :param Protocol protocol: protocol to use if no parent specified |
| 240 | (kwargs) |
| 241 | :param str main_resource: use this resource instead of parent resource |
| 242 | (kwargs) |
| 243 | :param bool download_attachments: whether or not to |
| 244 | download attachments (kwargs) |
| 245 | """ |
| 246 | if parent and con: |
| 247 | raise ValueError('Need a parent or a connection but not both') |
| 248 | self.con = parent.con if parent else con |
| 249 | |
| 250 | # Choose the main_resource passed in kwargs over parent main_resource |
| 251 | main_resource = kwargs.pop('main_resource', None) or ( |
| 252 | getattr(parent, 'main_resource', None) if parent else None) |
| 253 | |
| 254 | super().__init__( |
| 255 | protocol=parent.protocol if parent else kwargs.get('protocol'), |
| 256 | main_resource=main_resource, |
| 257 | attachment_name_property='subject', attachment_type='message_type') |
| 258 | |
| 259 | download_attachments = kwargs.get('download_attachments') |
| 260 | |
| 261 | cloud_data = kwargs.get(self._cloud_data_key, {}) |
| 262 | cc = self._cc # alias to shorten the code |
| 263 | |
| 264 | # internal to know which properties need to be updated on the server |
| 265 | self._track_changes = TrackerSet(casing=cc) |
| 266 | self.object_id = cloud_data.get(cc('id'), kwargs.get('object_id', None)) |
| 267 | |
| 268 | self.__inference_classification = cloud_data.get(cc('inferenceClassification'), None) |
| 269 | |
| 270 | self.__created = cloud_data.get(cc('createdDateTime'), None) |
| 271 | self.__modified = cloud_data.get(cc('lastModifiedDateTime'), None) |
| 272 | self.__received = cloud_data.get(cc('receivedDateTime'), None) |
no outgoing calls