【问题标题】:Accessing Chat Folder in Python Using Imaplib使用 Imaplib 在 Python 中访问聊天文件夹
【发布时间】:2011-12-30 02:59:15
【问题描述】:

我正在尝试使用 imaplib 访问聊天文件夹,但无法访问。代码mail.select("Chats") 不起作用,因为“聊天”实际上不是标签。

如何访问“聊天”文件夹中的电子邮件?

【问题讨论】:

    标签: python imaplib


    【解决方案1】:

    您想通过 imap 访问的任何文件夹。邮件服务器应该允许。

    例如:对于 gmail,请查看下图,了解如何设置 imap 的访问权限。

    这里,“在 IMAP 中显示”应该检查“聊天”文件夹。

    然后,尝试下面的代码 sn-ps:

    sock = imaplib.IMAP4_SSL("imap.gmail.com", 993)
    sock.login("your Email Id", "Password")
    lb_list = sock.list() # print
    #search for "Chats" folder and its signature
    #here, it is "[Gmail]/Chats"
    sock.select("[Gmail]/Chats", True)
    sock.search(None, '(ALL)')
    resp, data = sock.fetch('1:*', '(RFC822)')
    

    希望对您有所帮助。

    【讨论】:

    • 如何更改搜索条件。聊天邮箱可能会变得很长,无法阅读。
    猜你喜欢
    • 2017-10-29
    • 1970-01-01
    • 2014-04-14
    • 2023-03-31
    • 2016-03-10
    • 2014-02-09
    • 1970-01-01
    • 2013-03-30
    • 1970-01-01
    相关资源
    最近更新 更多