I can't Read Outlook Email with Python on Linux

I need to do an email automation. For this I need to read an email from Outlook and then send it after configuring some data.

The problem is that all the tutorials I've seen say to use the Outlook application installed on the computer. As I use Linux I can't do this. To read the email using Gmail, I did the following:

import datetime

from imap_tools import MailBox, AND

user = "myemail@gmail.com"
password = "anypassword"
#This password is an "App Password" that I need to configure within Gmail.


my_email = MailBox("imap.gmail.com").login(user, password)


today = datetime.date.today()


list_emails = my_email.fetch(AND(from_="", date=today, subject=""))

for email in list_emails:
    print(email.text)

How can I adapt the code for Outlook?

PS: In Gmail it is possible to set an "App Password". I didn't get this in Outlook.

Back to Top