views:

178

answers:

3

I have to process a file everyday. This file is sent to my Email once everyday. If I can get to this email once every day and download the attachment, that had be awesome. Is it even remotely possible to do such a thing?

Thanks!

+1  A: 

This is certainly possible. Check out imaplib in Python's standard library; with it doing what you want should be quite straightforward. Also, you can process zip files directly in Python using the zipfile library.

taleinat
+2  A: 

Please see http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail for a practical example.

Tarantula
Awesome! You saved me a lot of time. I wonder why my search didn't give me that link... Thank you!
ThinkCode
Your're welcome ThinkCode =)
Tarantula
+1  A: 

Your best bet is to create an IMAP Folder for your daily emails to be sent to and then create a filter in GMail to send those files there. Your Python script can then check ONLY that folder on some interval and assume that whatever ends up in there is the file you want.

A quick search yielded sooo many results for IMAP fetching examples in Python, I'll leave that part up to you, but I will say that libgmail looks pretty neat.

Mark B.
Thank you so much!
ThinkCode