imaplib

About Microsoft turning off IMAP protocol communication. When I use imaplib in python I get this error: b'LOGIN failed'

About Microsoft turning off IMAP protocol communication. When I use imaplib in python I get this error: b'LOGIN failed' Question: My sample code block; import imaplib try: userName = "[email protected]" passwd = "***" SMTP = "outlook.office365.com" Port = "993" imapSession = imaplib.IMAP4_SSL(SMTP, Port) imapSession.login(userName, passwd) except Exception as e: print(e) Return: error: b’LOGIN failed.’ I’m …

Total answers: 1

Searching for UTF-8 encoded subjects with imaplib

Searching for UTF-8 encoded subjects with imaplib Question: I have some working code to fetch mail bodies and I want to filter the subject with a non-ascii string. Other forums suggest using the .uid class to do so, but the behavior is not logic to me. Current code: import imaplib import email username = secret …

Total answers: 2

Read email in python 3.7 using imaplib with HTML body and attachments in the email

Read email in python 3.7 using imaplib with HTML body and attachments in the email Question: I would really appreciate if someone can help me with this issue. I have implemented the below code to read “unread emails from gmail inbox”. I need to print “To”, “From”, “Subject”, “Body” and “save attachments in a specified …

Total answers: 2

using imaplib.IMAP4_SSL in multiple processes

using imaplib.IMAP4_SSL in multiple processes Question: I want to reuse imaplib.IMAP4_SSL instance over many processes so I don’t have to login multiple times. Here is some code: import imaplib from multiprocessing import Process def fetch(mail_client): mail_client.uid(‘fetch’, b’1′, ‘BODY[TEXT]’) def main(): c = imaplib.IMAP4_SSL(‘imap.gmail.com’) c.login(user=’**’, password=’***’) c.select(‘inbox’) procs = [Process(target=fetch, args=(c,)) for _ in range(100)] for …

Total answers: 3

Python 3: Move email to trash by uid (imaplib)

Python 3: Move email to trash by uid (imaplib) Question: I want to move an email from my inbox to the trash folder, I do not want the email permanently deleted, I want it to go through the process of waiting 30 days in the trash to be permanently deleted. 1.Logged in: mail = imaplib.IMAP4_SSL(‘imap.gmail.com’) …

Total answers: 1

'str' object has no attribute 'decode'. Python 3 error?

'str' object has no attribute 'decode'. Python 3 error? Question: Here is my code: import imaplib from email.parser import HeaderParser conn = imaplib.IMAP4_SSL(‘imap.gmail.com’) conn.login(‘[email protected]’, ‘password’) conn.select() conn.search(None, ‘ALL’) data = conn.fetch(‘1’, ‘(BODY[HEADER])’) header_data = data[1][0][1].decode(‘utf-8′) At this point I get the error message: AttributeError: ‘str’ object has no attribute ‘decode’ Python 3 doesn’t have str.decode() …

Total answers: 16

How to understand the equal sign '=' symbol in IMAP email text?

How to understand the equal sign '=' symbol in IMAP email text? Question: I am currently using Python imaplib to process email text. I use fetch command to fetch the raw data email from GMail server. However, I found one thing really tricky – the equal sign ‘=’. It is not a normal equal sign …

Total answers: 1

Extract information from Gmail with Python

Extract information from Gmail with Python Question: I have come through solutions to extract useful information from selected received emails in Gmail mailbox. Aim in this example is to fetch all mails sent from a newsletter providing monthly prices for petroleum. You can freely subscribe to such a newsletter on EIA website. All such newsletter …

Total answers: 2