79598250

Date: 2025-04-29 11:31:12
Score: 0.5
Natty:
Report link

This question has already been answered on this post.

While it is possible to use imaplib directly I would recommend using a more user friendly library like imap_tools:

with MailBox('imap.mail.com').login('[email protected]', 'pwd', initial_folder='INBOX') as mailbox:

    # MOVE all messages from current folder to INBOX/folder2
    mailbox.move(mailbox.uids(), 'INBOX/folder2')

For the specific case of Google Mail I would recommend using their Python API . For example I wrote a small program to filter emails using Python and the Google API, you can find the code on Github .

upvote them, not me

Reasons:
  • Blacklisted phrase (0.5): upvote
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: mr-chen-rui