diff --git a/simplegmail/attachment.py b/simplegmail/attachment.py index 689248f..3b10c13 100644 --- a/simplegmail/attachment.py +++ b/simplegmail/attachment.py @@ -7,7 +7,7 @@ import base64 # for base64.urlsafe_b64decode import os # for os.path.exists -from typing import Optional +from typing import Optional, List, Dict class Attachment(object): """ @@ -21,6 +21,7 @@ class should not be manually instantiated. att_id: The id of the attachment. filename: The filename associated with the attachment. filetype: The mime type of the file. + headers: The headers of the attachment. data: The raw data of the file. Default None. Attributes: @@ -30,6 +31,7 @@ class should not be manually instantiated. id (str): The id of the attachment. filename (str): The filename associated with the attachment. filetype (str): The mime type of the file. + headers: The headers of the attachment. data (bytes): The raw data of the file. """ @@ -42,6 +44,7 @@ def __init__( att_id: str, filename: str, filetype: str, + headers: Optional[List[Dict]], data: Optional[bytes] = None ) -> None: self._service = service @@ -50,6 +53,7 @@ def __init__( self.id = att_id self.filename = filename self.filetype = filetype + self.headers = headers or [] self.data = data def download(self) -> None: diff --git a/simplegmail/gmail.py b/simplegmail/gmail.py index 67aa2aa..f2ab8f4 100644 --- a/simplegmail/gmail.py +++ b/simplegmail/gmail.py @@ -826,7 +826,7 @@ def _build_message_from_ref( elif part['part_type'] == 'attachment': attm = Attachment(self.service, user_id, msg_id, part['attachment_id'], part['filename'], - part['filetype'], part['data']) + part['filetype'], part['headers'], part['data']) attms.append(attm) return Message( @@ -892,6 +892,7 @@ def _evaluate_message_payload( 'filetype': payload['mimeType'], 'filename': filename, 'attachment_id': att_id, + 'headers': payload['headers'], 'data': None }