aboutsummaryrefslogtreecommitdiffstats
path: root/python/download_emails.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/download_emails.py')
-rw-r--r--python/download_emails.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/python/download_emails.py b/python/download_emails.py
index 5e0eb95b..be18b1f7 100644
--- a/python/download_emails.py
+++ b/python/download_emails.py
@@ -79,7 +79,8 @@ def msg_content(msg):
"""Extract subject and body from a gmail message"""
subject = [x['value'] for x in msg['payload']['headers'] if x['name']=='Subject'][0]
content = base64.b64decode(msg['payload']['body']['data']).decode('utf-8')
- return subject, content
+ date = msg['internalDate'] ## date /1000 to get timestamp
+ return subject, content, date
def update_emails():
"""Download new emails that were labeled swaptions."""
@@ -91,13 +92,14 @@ def update_emails():
for msg in ListMessagesWithLabels(service, 'me', labelsdict['swaptions']):
if msg['id'] not in current_msgs:
try:
- subject, content = msg_content(get_msg(service, 'me', msg['id']))
+ subject, content, date = msg_content(get_msg(service, 'me', msg['id']))
except (binascii.Error, KeyError):
print("error decoding {0}".format(msg['id']))
continue
else:
email = p / msg['id']
with email.open("w") as fh:
+ fh.write(date + "\r\n")
fh.write(subject + "\r\n")
fh.write(content)