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


Groups > comp.lang.python > #76674

Re: how to copy emails into local directory?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.004
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'skip:[ 20': 0.04; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:\\ 10': 0.09; 'subject:into': 0.09; 'python': 0.11; '"/"': 0.16; 'code?': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'scratch': 0.16; 'implementing': 0.19; '(the': 0.22; 'import': 0.22; 'header:User-Agent:1': 0.23; 'skip:" 20': 0.27; 'header:X-Complaints-To:1': 0.27; '[1]': 0.29; 'ideal': 0.29; 'writes:': 0.31; 'skip:c 30': 0.32; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'version': 0.36; 'subject:?': 0.36; 'application': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'easy': 0.60; 'subject:emails': 0.60; 'account': 0.65; 'mailbox': 0.68; 'received:89': 0.85
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Akira Li <4kir4.1i@gmail.com>
Subject Re: how to copy emails into local directory?
Date Wed, 20 Aug 2014 20:21:57 +0400
References <53F49010.9020008@gmail.com>
Mime-Version 1.0
Content-Type text/plain
X-Gmane-NNTP-Posting-Host 89.169.229.68
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
Cancel-Lock sha1:W4UNoeDqjJQV1Kf2Vd+8Jj/P9cM=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.13215.1408551739.18130.python-list@python.org> (permalink)
Lines 39
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408551739 news.xs4all.nl 2918 [2001:888:2000:d::a6]:42910
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76674

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web