I am making an application where I have to read emails from my inbox, Outlook.
For this I am using the O365 library with python.
The authentication is done correctly, then I try to get the folder where I have the emails:
inbox = mailbox.get_folder(folder_name='Inbox')
I perform the query, with the created_date_time parameter:
query_email = mailbox.new_query()
query_email = query_email.on_attribute('created_date_time'). \
greater(datetime(from_date_time.year, from_date_time.month, from_date_time.day)).\
chain('and').on_attribute('isRead').equals(True).order_by('created_date_time')
Launch the query and read the results:
for message in inbox.get_messages(limit=999,
query=query_email,
download_attachments=False):
The problem is that when I read the results it returns very few emails and most of them are responses, for example if I have 50, 20 responses and 30 received, it returns 10 responses and 5 received.
Can I add a condition to the query to search for an email address in the specified folder?