简体   繁体   中英

Fetching E-mails 10 by 10 or n by n using Imap_tools python

I'm using Imap_tools library and I'm trying to fetch the emails in a folder 10 by 10 (for pagination and performance purposes) when I tried using limit and passing a tuple to it like so:

mails = mailbox.fetch(reverse = True, headers_only = True, mark_seen=False, limit=(10,20)) 

I got the following error

File "C:\Python39\lib\site-packages\imap_tools\mailbox.py", line 147, in fetch
    assert type(limit_range) is slice
AssertionError

Is there anyone who has a solution or a better approach? I will be thankful!

Expected it to ignore the 1st 10 Emails and fetch the second 10 Emails!

Seems like the library is looking for a slice:
(10, 20) => slice(11, 21)
11th mail to 20th mail for a total of 10 mails, considering first mail's index is 1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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