Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53020 > unrolled thread

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

Started byrob@attoenterprises.com
First post2013-08-26 16:34 -0700
Last post2013-08-26 17:18 -0700
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Imaplib & Gmail - cannot move from inbox to custom folder (message remains in both) rob@attoenterprises.com - 2013-08-26 16:34 -0700
    Re: Imaplib & Gmail - cannot move from inbox to custom folder (message remains in both) MRAB <python@mrabarnett.plus.com> - 2013-08-27 00:56 +0100
      Re: Imaplib & Gmail - cannot move from inbox to custom folder (message remains in both) rob@attoenterprises.com - 2013-08-26 17:18 -0700

#53020 — Imaplib & Gmail - cannot move from inbox to custom folder (message remains in both)

Fromrob@attoenterprises.com
Date2013-08-26 16:34 -0700
SubjectImaplib & Gmail - cannot move from inbox to custom folder (message remains in both)
Message-ID<c7b0fe9a-990f-403a-b39b-0f080f8571a6@googlegroups.com>
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?

[toc] | [next] | [standalone]


#53021

FromMRAB <python@mrabarnett.plus.com>
Date2013-08-27 00:56 +0100
Message-ID<mailman.249.1377561358.19984.python-list@python.org>
In reply to#53020
On 27/08/2013 00:34, rob@attoenterprises.com wrote:
> 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'?

[toc] | [prev] | [next] | [standalone]


#53022

Fromrob@attoenterprises.com
Date2013-08-26 17:18 -0700
Message-ID<b8ce0c51-faab-4641-94b7-fd1077550d07@googlegroups.com>
In reply to#53021
On Monday, August 26, 2013 5:56:09 PM UTC-6, MRAB wrote:
> On 27/08/2013 00:34, rob@attoenterprises.com wrote:
> 
> > 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'?

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.  

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web