email - How can I adapt this gmail reading code for python3? (from python) -


the following code works in python2 read gmail inbox. cannot run in python3 after put brackets around things need print.

import smtplib import time import imaplib import email  from_email  = "email" from_pwd    = "pass" smtp_server = "imap.gmail.com" smtp_port   = 993  mail = imaplib.imap4_ssl(smtp_server) mail.login(from_email,from_pwd) mail.select('inbox')  type, data = mail.search(none, 'all') mail_ids = data[0]  id_list = mail_ids.split()    first_email_id = int(id_list[0]) latest_email_id = int(id_list[-1])   in range(latest_email_id,first_email_id, -1):     typ, data = mail.fetch(i, '(rfc822)' )      response_part in data:         if isinstance(response_part, tuple):             msg = email.message_from_string(response_part[1])             email_subject = msg['subject']             email_from = msg['from']             print('from : ' + email_from + '\n')             print('subject : ' + email_subject + '\n') 

it gives me error:

    data = data + b' ' + arg                                                                     typeerror: can't concat bytes int   


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -