Menu

#11 Need way to manipulate a large number of messages at once

open
nobody
None
5
2005-12-23
2005-12-23
Shlomi Fish
No

Hi!

At the moment, one can only delete only one message at
the time. However, this is time consuming, and Google
will eventually block your HTTP requests.

The gmail.com HTTP interface allows to act on more than
one message at once. This was done (as an effect of my
request) in the Mail::Webmail::Gmail module:

http://search.cpan.org/dist/Mail-Webmail-Gmail/

Which is at the moment broken due to a change in the
gmail login semantics.

Please implement this feature, because there's one
label where I have over 8,000 messages that I'd like to
delete.

Regards,

Shlomi Fish

Discussion

  • Anonymous

    Anonymous - 2006-10-25

    Logged In: YES
    user_id=1136737

    I created this script for this:

    #!/usr/bin/env python
    '''
    delete_all.py -- Demo to delete all messages in folder
    License: GPL 2.0
    Copyright 2006 leogregianin@users.sourceforge.net
    '''

    import sys
    from getpass import getpass
    import libgmail

    if __name__ == "__main__":
    try:
    name = sys.argv[1]
    except IndexError:
    name = raw_input("Gmail account name: ")

    pw = getpass("Password: ")

    ga = libgmail.GmailAccount(name, pw)

    print "\nPlease wait, logging in..."

    try:
    ga.login()
    except libgmail.GmailLoginFailure,e:
    print "\nLogin failed. (%s)" % e.message
    sys.exit(1)
    else:
    print "Login successful.\n"

    FOLDER_list = raw_input('Choose a folder (inbox,
    starred, all, drafts, sent, spam): ')
    folder = ga.getMessagesByFolder(FOLDER_list)

    choice = raw_input('\nDo you really delete all messages
    in folder? [yes/no] ')
    if choice in ['yes', 'y']:
    for thread in folder:
    print thread.id, len(thread), thread.subject,
    'delete ok!\n'
    ga.trashMessage(thread)
    print '\nDelete all messages in folder sucessful!\n'

    :P leonardo.

     
  • Shlomi Fish

    Shlomi Fish - 2006-11-17

    Logged In: YES
    user_id=35062
    Originator: YES

    Unfortunately this snippet still deletes one thread at a time, and would eventually be blocked by gmail. There's a way in gmail to delete multiple messages at a time - take a look at Mail::Webmail::Gmail (which has been fixed since my last report).

    Note that now gmail has a UI option to select all messages in a label, including those that are not visible.

     
  • Anonymous

    Anonymous - 2007-01-30

    Logged In: YES
    user_id=1136737
    Originator: NO

    replace this:
    << folder = ga.getMessagesByFolder(FOLDER_list)
    for this:
    >> folder = ga.getMessagesByFolder(FOLDER_list, allPages=True)

    and, this:
    << ga.trashMessage(thread)
    for this:
    >> ga.trashThread(thread)

    perhaps the gmail blocks you with little frequency ;P

     

Log in to post a comment.