gpt4 book ai didi

python - imap 不允许使用 gmail 文件夹 - mail.select 'inbox' 以外的文件夹

转载 作者:行者123 更新时间:2023-12-05 03:10:47 25 4
gpt4 key购买 nike

基本上如标题所述,我正在使用

mail.select("inbox")
result, data = mail.search(None, "ALL")
ids = data[0] # data is a list.
id_list = ids.split() # ids is a space separated string
latest_email_id = id_list[-1] # get the latest

从收件箱中获取最新的电子邮件。从理论上讲,您可以将“收件箱”更改为 gmail 中的另一个标签或文件夹(我的标签和文件夹使用 mail.list() 显示得很好)。我想使用我的标签“Server Status/Leviathan”,但它会抛出错误

Traceback (most recent call last):
File "E:\False Apparition\Desktop\test3.py", line 18, in <module>
mail.select("Server Status/Leviathan")
File "C:\Users\Ancient Abysswalker\AppData\Local\Programs\Python\Python36-32\lib\imaplib.py", line 737, in select
typ, dat = self._simple_command(name, mailbox)
File "C:\Users\Ancient Abysswalker\AppData\Local\Programs\Python\Python36-32\lib\imaplib.py", line 1188, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "C:\Users\Ancient Abysswalker\AppData\Local\Programs\Python\Python36-32\lib\imaplib.py", line 1019, in _command_complete
raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: SELECT command error: BAD [b'Could not parse command']

这与标签在 gmail 上不存在的情况不同...

Traceback (most recent call last):
File "E:\False Apparition\Desktop\test3.py", line 20, in <module>
result, data = mail.search(None, "ALL")
File "C:\Users\Ancient Abysswalker\AppData\Local\Programs\Python\Python36-32\lib\imaplib.py", line 715, in search
typ, dat = self._simple_command(name, *criteria)
File "C:\Users\Ancient Abysswalker\AppData\Local\Programs\Python\Python36-32\lib\imaplib.py", line 1188, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "C:\Users\Ancient Abysswalker\AppData\Local\Programs\Python\Python36-32\lib\imaplib.py", line 936, in _command
', '.join(Commands[name])))
imaplib.error: command SEARCH illegal in state AUTH, only allowed in states SELECTED

我错过了什么吗?也许是图书馆?

最佳答案

在您的文件夹名称周围添加引号。 Imaplib 应该为您做这件事,但它不会:mail.select('"folder with space"')

关于python - imap 不允许使用 gmail 文件夹 - mail.select 'inbox' 以外的文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38760698/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com