Imaplib & Gmail - cannot move from inbox to custom folder (messageremains in both)

R

rob

I am using Imaplib and connecting to a Gmail account. I am issuing commands to copy the email to a custom folder then issuing delete. After expunge message still remains in inbox and customer folder.

# COPY EMAIL TO FOLDER
copyStatus = m.copy(emailid, 'CIRIMPORTED')
print 'id of message copied is: %s status: %s' % (emailid,copyStatus)

# SET THE MESSAGE TO HAVE '\Deleted' FLAG (EXPUNGE WILL COMPLETE DELETE PROCESS)
storeStatus = m.store(emailid,"+FLAGS", r'(\Deleted)')
print 'id of message stored is: %s status: %s %s' % (emailid,storeStatus[0],storeStatus[1])
#print '******'

#DELETES ANY EMAIL MARKED \Deleted
m.expunge()
m.close()
m.logout()

Does anyone have any imaplib code the works with Gmail to move from inbox to another folder?
 
M

MRAB

I am using Imaplib and connecting to a Gmail account. I am issuing commands to copy the email to a custom folder then issuing delete. After expunge message still remains in inbox and customer folder.

# COPY EMAIL TO FOLDER
copyStatus = m.copy(emailid, 'CIRIMPORTED')
print 'id of message copied is: %s status: %s' % (emailid,copyStatus)

# SET THE MESSAGE TO HAVE '\Deleted' FLAG (EXPUNGE WILL COMPLETE DELETE PROCESS)
storeStatus = m.store(emailid,"+FLAGS", r'(\Deleted)')
print 'id of message stored is: %s status: %s %s' % (emailid,storeStatus[0],storeStatus[1])
#print '******'

#DELETES ANY EMAIL MARKED \Deleted
m.expunge()
m.close()
m.logout()

Does anyone have any imaplib code the works with Gmail to move from inbox to another folder?
There's an example in docs which says:

M.store(num, '+FLAGS', '\\Deleted')

You have:

m.store(emailid,"+FLAGS", r'(\Deleted)')

Could it be that the flags should be r'\Deleted'?
 
R

rob

I am using Imaplib and connecting to a Gmail account. I am issuing commands to copy the email to a custom folder then issuing delete. After expunge message still remains in inbox and customer folder.

# COPY EMAIL TO FOLDER
copyStatus = m.copy(emailid, 'CIRIMPORTED')
print 'id of message copied is: %s status: %s' % (emailid,copyStatus)

# SET THE MESSAGE TO HAVE '\Deleted' FLAG (EXPUNGE WILL COMPLETE DELETE PROCESS)
storeStatus = m.store(emailid,"+FLAGS", r'(\Deleted)')
print 'id of message stored is: %s status: %s %s' % (emailid,storeStatus[0],storeStatus[1])
#print '******'

#DELETES ANY EMAIL MARKED \Deleted




Does anyone have any imaplib code the works with Gmail to move from inbox to another folder?

There's an example in docs which says:



M.store(num, '+FLAGS', '\\Deleted')



You have:



m.store(emailid,"+FLAGS", r'(\Deleted)')



Could it be that the flags should be r'\Deleted'?

I have tried it with the variations on the web of \\Deleted, r'\Deleted, and \Deleted. The Delete works because I see in the status 'Deleted'. However it does not remove from Inbox.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,732
Latest member
ArronPalin

Latest Threads

Top