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


Groups > comp.lang.python > #75791

Re: How to delete letters automatically with imaplib?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <elearn2014@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.060
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'subject:skip:a 10': 0.09; 'subject:How': 0.10; 'finney': 0.16; 'wrote:': 0.18; 'command': 0.22; 'header:User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'writes:': 0.31; 'subject:with': 0.35; 'operations': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'received:10': 0.37; 'message-id:@gmail.com': 0.38; 'ben': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'delete': 0.39; 'to:addr:python.org': 0.39; 'address.': 0.39; 'skip:p 20': 0.39; 'how': 0.40
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=U3vfv03MoEBly1ChZMcF+rz3i8EyFuU9E7XiRKEUViU=; b=bYr+cS8fPEGMp8kogOhEE7WanXYEV/tZlzvzeZJDQxIMglrUEG7gFbMhPHqY8O7a9l wiCTTeBzU96oQwGVCRSMqKYqPWc+7xcDeFu855TidPjFgWr/fCt3siBm2CzU0dvjwTlB HPNey1RPJ1fM65GUoaA0JMoZUNh0HQdF7E8UmkSj/9KyY+fg8Yok2gufq4uvyuTmoLsO qajsRu/UpE78lHAjZ0mlg3iJB0LSKDgOy3NUWMveTci8l5NLMbC9EhZY8ESrC8hClJ28 12kqo87FpADWZhCscTwS9aAfb4avB5jcLde45ON6qXBBXhlAlkitAR2umX0wOKADU1W+ gysg==
X-Received by 10.70.91.167 with SMTP id cf7mr7906579pdb.3.1407323963606; Wed, 06 Aug 2014 04:19:23 -0700 (PDT)
Date Wed, 06 Aug 2014 19:19:18 +0800
From elearn <elearn2014@gmail.com>
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0
MIME-Version 1.0
To Ben Finney <ben+python@benfinney.id.au>, python-list@python.org
Subject Re: How to delete letters automatically with imaplib?
References <53E1EF26.4020508@gmail.com> <85d2ceasjp.fsf@benfinney.id.au>
In-Reply-To <85d2ceasjp.fsf@benfinney.id.au>
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
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.12695.1407323966.18130.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1407323966 news.xs4all.nl 2905 [2001:888:2000:d::a6]:55461
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75791

Show key headers only | View raw


and how to write the delete command with imaplib?
On 8/6/2014 5:14 PM, Ben Finney wrote:
> elearn <elearn2014@gmail.com> writes:
>
>> status,  data=  con.search(None,  "ALL")
>> print(len(data[0].split()))
>> 48
>> typ,  data=  con.search(None,  'Body',  '"xxx@gmail.com"')
>>>>>   data
>> [b'1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
>>   32 33 34 35 36 37 44']
>>
>> len(data[0].split())
>> 36
>>
>> How can i delete 48-36=12 letters?
> Set operations are designed for this::
>
>      # Construct a set of all message numbers.
>      status, data = con.search(None, "ALL")
>      ids_of_all_messages = set(data[0].split())
>
>      # Construct a set of messages mentioning the address.
>      status, data = con.search(None, 'Body', '"xxx@gmail.com"')
>      ids_of_messages_containing_address = set(data[0].split())
>
>      # Get the messages to delete.
>      ids_of_messages_to_delete = (
>              ids_of_all_messages - ids_of_messages_containing_address)
>

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


Thread

Re: How to delete letters automatically with imaplib? elearn <elearn2014@gmail.com> - 2014-08-06 19:19 +0800

csiph-web