diff --git a/simplegmail/gmail.py b/simplegmail/gmail.py index 2c9aba7..4446b1c 100644 --- a/simplegmail/gmail.py +++ b/simplegmail/gmail.py @@ -66,6 +66,7 @@ def __init__( ) -> None: self.client_secret_file = client_secret_file self.creds_file = creds_file + self._resultSizeEstimate = 0 try: # The file gmail_token.json stores the user's access and refresh @@ -516,6 +517,9 @@ def get_messages( includeSpamTrash=include_spam_trash ).execute() + if 'resultSizeEstimate' in response: + self._resultSizeEstimate = response['resultSizeEstimate'] + message_refs = [] if 'messages' in response: # ensure request was successful message_refs.extend(response['messages']) @@ -530,6 +534,9 @@ def get_messages( pageToken=page_token ).execute() + if 'resultSizeEstimate' in response: + self._resultSizeEstimate = response['resultSizeEstimate'] + message_refs.extend(response['messages']) return self._get_messages_from_refs(user_id, message_refs, @@ -988,3 +995,7 @@ def _get_alias_info( res = req.execute() return res + + @property + def resultSizeEstimate(self): + return self._resultSizeEstimate