具有GMail偏移量uid的Imaplib [英] Imaplib with GMail offsets uids

查看:80
本文介绍了具有GMail偏移量uid的Imaplib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有范围参数的python ImapLib查询我的gmail收件箱,但是返回的uid与我要求的偏移.我的要求如下:

I'm querying my gmail inbox using pythons ImapLib with a range parameter, but my returned uids are offset from what I request. My request is as follows:

M = imaplib.IMAP4_SSL('imap.gmail.com')
M.login(USER, PASS)
# Choose the inbox for finding mail
M.select('INBOX')
rv, data = M.uid("search", None, '29540:*')

这将返回单个UID 2972​​5.

This returns a single UID, 29725.

如果我从开始的范围中减去421(通过反复试验发现),则会得到从29540到29725的uid的完整列表.我很困惑.可能是它未在此范围内使用UID,并且在某种程度上遇到了删除电子邮件的问题?

If I subtract 421 (found by trial and error) from the beginning range I get the full list of uids from from 29540 to 29725. I am stumped. Could it be that it is not using UID in this range and is somehow having problems with deleted emails?

推荐答案

似乎 M.uid 只是简单地指定了返回值将是UID,因此仍然有必要指定参数发送的将是UID,而不是消息ID.可以解决此问题:

It seems like M.uid simply specifies that the return value will be UID's, so it is still necessary to specify that the parameters sent will be UID's and not message ID's. This fixes it:

rv, data = M.uid("search", None, 'UID', '29540:*')

这篇关于具有GMail偏移量uid的Imaplib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆