flagging multiple messages in one command with imaplib?

Discussion in 'Python' started by Mr. Magoo, Sep 1, 2003.

  1. Mr. Magoo

    Mr. Magoo Guest

    I'm working with imaplib. I'm trying to flag (or move or copy - anything
    that takes a message_set as an argument) a bunch of messages with one
    command and am having trouble.

    ===

    def check_error(typ, data):
    if (typ != 'OK'):
    print typ
    print data[0]
    sys.exit(1)

    imapcon = imaplib.IMAP4(HOST)
    imapcon.login_cram_md5(USER, PASS)

    typ, data = imapcon.select('INBOX')
    check_error(typ, data)

    typ, data = imapcon.search(None, 'NOT', 'FLAGGED', 'SINCE',
    '28-AUG-2003')
    check_error(typ, data)

    print data[0]

    typ, data = imapcon.store(data[0], "+FLAGS.SILENT", r'(\FLAGGED)')
    print typ
    print data
    check_error(typ, data)


    ===

    When my mail client does this it sends the message numbers unquoted, but
    imaplib seems to quote them, leading to

    imaplib.error: STORE command error: BAD ['Bogus attribute list in STORE']


    What am I doing wrong? How do I work with multiple messages in one
    command. (The primary consideration here is speed - 1 command is much
    faster than N when N is large.)

    Thanks.
    M.
    Mr. Magoo, Sep 1, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raghul
    Replies:
    1
    Views:
    599
    Kartic
    Feb 23, 2005
  2. Tony Meyer
    Replies:
    1
    Views:
    425
    Raghul
    Feb 23, 2005
  3. Mario T. Lanza

    Best Practice: Flagging Changed Rows

    Mario T. Lanza, Feb 16, 2004, in forum: ASP General
    Replies:
    1
    Views:
    82
    middletree
    Feb 16, 2004
  4. Mumia W.

    [VOTE] Multi-post flagging 'bot

    Mumia W., Aug 14, 2006, in forum: Perl Misc
    Replies:
    0
    Views:
    81
    Mumia W.
    Aug 14, 2006
  5. Mumia W.
    Replies:
    12
    Views:
    189
    John Bokma
    Aug 15, 2006
Loading...

Share This Page