[Python] How to read email content in Python 3

Discussão em 'Python' iniciado por Stack, Agosto 19, 2025.

  1. Stack

    Stack Membro Participativo

    I've tried many code to access and read email content, for example, about Gmail i only can do authentication and with Outlook i have code that can read email but it's encrypted...but now it only access email and doesn't output with encrypted information. So i need help to solve this. Thanks

    Here's the code:

    import imaplib
    import base64

    email_user = input('Email: ')
    email_pass = input('Password: ')

    M = imaplib.IMAP4_SSL('imap-mail.outlook.com', 993)
    M.login(email_user, email_pass)
    M.select()
    typ, data = M.search(None, 'ALL')
    for num in data[0].split():
    typ, data = M.fetch(num, '(RFC822)')
    num1 = base64.b64decode(num1)
    data1 = base64.b64decode(data)
    print('Message %s\n%s\n' % (num, data[0][1]))
    M.close()
    M.logout()

    Continue reading...

Compartilhe esta Página