我通过IMAP获取了Gmail的邮件。但输出只给出了邮件的标题。现在作为领先一步,我想获取邮件的全部细节。
我获取邮件标题的代码是:
表示数据[0]中的num .split():
rv, data = M.fetch(num, '(RFC822)')
if rv != 'OK':
print ("ERROR getting message", num)
return
msg = email.message_from_string(data[0][1])
decode = email.header.decode_header(msg['Subject'])[0]
subject = unicode(decode[0])
print ('Message %s: %s' % (num, subject))
print ('Raw Date:', msg['Date'])
# Now convert to local date-time
date_tuple = email.utils.parsedate_tz(msg['Date'])
if date_tuple:
local_date = datetime.datetime.fromtimestamp(
email.utils.mktime_tz(date_tuple))
print ("Local Date:")
local_date.strftime("%a, %d %b %Y %H:%M:%S")
有人可以指导我吗?