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 = getnewimapconne ction()
try:
typ,data = conn.select()
check_error((ty p,data))
#print "Number of messages in INBOX: ",data[0]
typ,all_message s = conn.search(Non e,'(ALL)')
check_error((ty p,data))
#mailboxes = conn.list()[1]
#for mb in mailboxes:
# print mb
#raise SystemExit
# Store all messages into another
typ,data = conn.copy(all_m essages,'"Publi cInbox"')
check_error((ty p,data))
finally:
conn.logout()
I get this error:
Traceback (most recent call last):
File "MailDaemon.py" , line 99, in ?
check_error((ty p,data))
File "MailDaemon.py" , line 15, in check_error
raise IMAPError((typ, data))
__main__.IMAPEr ror: ('NO', ["[TRYCREATE] Mailbox doesn't exist: 2"])
However, if I comment out the for loop that lists the mailboxes, I see this:
(\HasNoChildren ) "/" "PublicInbo x"
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