admin管理员组

文章数量:1122846

I want to create a basic script that can automatically sort all my emails (I use Outlook) into different folders. So let's say I got an email that came from [email protected], the script will create a folder called "company" if one doesn't already exist, and then move the email to that folder (with additional rules I'd add in the future).

I tried to do it with Python using the imaplib and imapclient libraries, and with NodeJS using imap:


EMAIL = '[email protected]'
PASSWORD = 'my_password'
IMAP = 'outlook.office365'

imap_ssl = imaplib.IMAP4_SSL(host=IMAP, port=993)

resp_code, response = imap_ssl.login(EMAIL, PASSWORD)
print("----------------")
print(resp_code)
print("----------------")
print(response)

Using both NodeJS and Python I tried to log into my email with my password and with an "App Password", but it does not work; I get a login error every time:

imaplib.IMAP4.error: b'LOGIN failed.'

Has anyone been through this? Did I miss a step?

本文标签: pythonScript to fetch my email and sort them to foldersStack Overflow