def diurnalPlot(headers):
""" diurnal plot of the emails,
with years running along the x axis
and times of day on the y axis.
"""
xday = []
ytime = []
for h in headers:
if len(h) > 1:
timestamp = mktime(parsedate(h[1][5:].replace('.',':')))
mailstamp = datetime.fromtimestamp(timestamp)
xday.append(mailstamp)
# Time the email is arrived
# Note that years, month and day are not important here.
y = datetime(2010,10,14,
mailstamp.hour, mailstamp.minute, mailstamp.second)
ytime.append(y)
plot_date(xday,ytime,'.',alpha=.7)
xticks(rotation=30)
return xday,ytime

Hello wolf, Thanks for you comment. The function get header retrieves the headers of all the emails from d days ago until now.

If you want to retrieve the emails you replied in a certain amount of time you have to get all the email in the inbox and the email in the outbox ('[Gmail]/Sent Mail' in my case) then you can iterate over the received mail and see the closes sent mail to that address. It's not a precise algorithm but it could give you a good approximation.

Hi Youngseok, the function parsedate returns None when it's not able to recognize the string. It may be your case. You should check the input of this function. It may be that the header that you are using is different that the one I used when I wrote this snippet.