By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,539 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,539 IT Pros & Developers. It's quick & easy.

imaplib question

P: n/a


I'm trying to write a very simple program that moves all messages from
INBOX into another folder.
I'm not sure what am I doing wrong. This is a very simple task. I
believe I need to call these methods:

- search -get all message UIDs in the INBOX
- copy -copy all messages to another folder
- store -mark all messages in INBOX as deleted
- expunge -delete them physically

Here is what I have now:

conn = getnewimapconnection()
typ,data =
#print "Number of messages in INBOX: ",data[0]
typ,all_messages =,'(ALL)')

#mailboxes = conn.list()[1]
#for mb in mailboxes:
# print mb
#raise SystemExit

# Store all messages into another
typ,data = conn.copy(all_messages,'"PublicInbox"')
I get this error:

Traceback (most recent call last):
File "", line 99, in ?
File "", line 15, in check_error
raise IMAPError((typ,data))
__main__.IMAPError: ('NO', ["[TRYCREATE] Mailbox doesn't exist: 2"])

However, if I comment out the for loop that lists the mailboxes, I see this:

(\HasNoChildren) "/" "PublicInbox"

I also tried 'PublicInbox' '/PublicInbox' and '/ PublicInbox' etc. but
none of them works. Most strangely, if I create a new mailbox with
create('TTT') then it creates a new mailbox successfuly.

Please help me


Jul 14 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.