get date from email

  • Thread starter Thomas Guettler
  • Start date
T

Thomas Guettler

Hi,

up to now I use this code to parse date values from emails:

msg=email.message_from_file(open(file_name))
date=None
date_str=msg.get('date')
if date_str:
date_tuple=email.utils.parsedate_tz(date_str)
if date_tuple:
date=datetime.datetime.fromtimestamp(email.utils.mktime_tz(date_tuple))
if date:
... # valid date found


Somehow this looks too complicated. Any chance to integrate the datetime module into the email module?

related: http://stackoverflow.com/questions/1790795/python-parsing-date-with-timezone-from-an-email
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top