Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76674 > unrolled thread

Re: how to copy emails into local directory?

Started byAkira Li <4kir4.1i@gmail.com>
First post2014-08-20 20:21 +0400
Last post2014-08-20 20:21 +0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: how to copy emails into local directory? Akira Li <4kir4.1i@gmail.com> - 2014-08-20 20:21 +0400

#76674 — Re: how to copy emails into local directory?

FromAkira Li <4kir4.1i@gmail.com>
Date2014-08-20 20:21 +0400
SubjectRe: how to copy emails into local directory?
Message-ID<mailman.13215.1408551739.18130.python-list@python.org>
luofeiyu <elearn2014@gmail.com> writes:

> import imaplib,email
> user="xxxx"
> password="yyyy"
> con=imaplib.IMAP4_SSL('imap.gmail.com')
> con.login(user,password)
> con.list()
> ('OK', [b'(\\HasNoChildren) "/" "INBOX"', b'(\\Noselect \\HasChildren)
> "/" "[Gma
> il]"', b'(\\HasNoChildren \\Junk) "/" "[Gmail]/&V4NXPpCuTvY-"',
> b'(\\HasNoChildr
> en \\Trash) "/" "[Gmail]/&XfJSIJZkkK5O9g-"', b'(\\HasNoChildren
> \\Flagged) "/" "
> [Gmail]/&XfJSoGYfaAc-"', b'(\\HasNoChildren \\Sent) "/"
> "[Gmail]/&XfJT0ZCuTvY-"'
> , b'(\\HasNoChildren \\All) "/" "[Gmail]/&YkBnCZCuTvY-"',
> b'(\\HasNoChildren \\D
> rafts) "/" "[Gmail]/&g0l6Pw-"', b'(\\HasNoChildren \\Important) "/"
> "[Gmail]/&kc
> 2JgQ-"'])
>
> Now, i want to  copy all the emails in the gmailbox of
> "[Gmail]/&kc2JgQ-"  (the important mailbox in my gmail"
> into local directory  "g:\emails",how can i do that in python code?

You could try an already-made application something like *gmvault*
instead of implementing the functionality from scratch on top of
imaplib. It is easy [1] to create a version that can perform the backup in
ideal conditions but it is much harder to take into account all nuances
to make it reliable.

[1]
http://stackoverflow.com/questions/348630/how-can-i-download-all-emails-with-attachments-from-gmail


--
Akira

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web