def process(msg: mailbox.MaildirMessage) -> Item: sender, address = parseaddr(msg["From"]) date = datetime.datetime.utcfromtimestamp( msg.get_date()).isoformat() # ISO 8601 format subject = msg["Subject"] content = "" for part in msg.walk(): if part.get_content_type() == "text/plain" or part.get_content_type( ) == "text/html": content += part.get_payload(decode=True).decode('utf-8') print(sender) print(address) print(date) print(subject) print(content) return Item(sender, address, date, subject, content)