【问题标题】:How do I move emails into folders using the IMAP library in python?如何使用 python 中的 IMAP 库将电子邮件移动到文件夹中?
【发布时间】:2020-06-02 21:04:15
【问题描述】:

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

试图将电子邮件从一个文件夹移动到另一个文件夹。我有要移动的电子邮件的 uid。

【问题讨论】:

  • 快速指针:检查 CAPABILITIES 是否可以移动,如果可用,请使用 `conn.uid('move', )。如果没有,请使用 uid('copy', ...)、uid('store', uid '\Deleted') 和 uid('expunge', uid)

标签: python gmail imap email imaplib


【解决方案1】:
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')

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-24
    • 1970-01-01
    • 2021-11-27
    • 2015-01-23
    • 2015-04-30
    • 2017-05-20
    相关资源
    最近更新 更多