Fixed bug
This commit is contained in:
parent
bc09145408
commit
6a12e2bb9d
|
@ -5,7 +5,7 @@ import email.header
|
|||
import datetime
|
||||
|
||||
def decode_mime_words(s):
|
||||
return u''.join(
|
||||
return ''.join(
|
||||
word.decode(encoding or 'utf8') if isinstance(word, bytes) else word
|
||||
for word, encoding in email.header.decode_header(s))
|
||||
|
||||
|
@ -27,14 +27,14 @@ def process_mailbox(mailbox, to = None):
|
|||
print('To: ', to)
|
||||
|
||||
print('From:', msg['From'])
|
||||
decode = email.header.decode_header(msg['Subject'])
|
||||
subject = decode_mime_words(decode)
|
||||
subject = decode_mime_words(msg['Subject'])
|
||||
|
||||
print('Subject: %s' % subject)
|
||||
print('Subject: %s' % decode_mime_words(msg['Subject']))
|
||||
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"))
|
||||
print()
|
||||
# with code below you can process text of email
|
||||
# if msg.is_multipart():
|
||||
# for payload in msg.get_payload():
|
||||
|
|
Loading…
Reference in New Issue