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

Hello,

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()
try:
typ,data = conn.select()
check_error((typ,data))
#print "Number of messages in INBOX: ",data[0]
typ,all_messages = conn.search(None,'(ALL)')
check_error((typ,data))

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

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

Traceback (most recent call last):
File "MailDaemon.py", line 99, in ?
check_error((typ,data))
File "MailDaemon.py", 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

Laszlo

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.