简体   繁体   English

如何使用 python 中的 IMAP 库将电子邮件移动到文件夹中?

[英]How do I move emails into folders using the IMAP library in python?

How do I move emails into folders using the IMAP library in python?如何使用 python 中的 IMAP 库将电子邮件移动到文件夹中?

Trying to move an email from one folder into another.试图将 email 从一个文件夹移动到另一个文件夹。 I have the uid of the emails that I want to move.我有要移动的电子邮件的 uid。

with MailBox('imap.mail.com').login('test@mail.com', 'pwd', initial_folder='INBOX') as mailbox:
    # MOVE all messages from current folder (INBOX) to folder2
    mailbox.move(mailbox.fetch(), 'INBOX/folder2')

Lib: https://github.com/ikvk/imap_tools库: https://github.com/ikvk/imap_tools

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM