0

I am writing an email client using IMAPClient. My goal now is to render the list of messages in my INBOX. The number of messages amount to around 4 thousand. The problem is that it takes ages to fetch these letters like this:

server = IMAPClient(HOST, use_uid=True, ssl=True)
server.login(USERNAME, PASSWORD)    
server.select_folder('INBOX')
messages = server.search(['NOT DELETED'])
response = server.fetch(messages, ['RFC822', 'BODY[TEXT]']) # TAKES AGES TO FINISH

It seem intuitive that I should ask for, say, the first 20 messages, and then if the user scrolls down, ask for the next chunk of 20 messages (sorted by date when the letter has been received). In other words, I should somehow paginate the fetch command, or make it lazy. But IMAPClient seems to be silent on this , though it seems like a major issue. Any ideas ?

1
  • Presumably messages is a list. Break it into sublists! Commented Jul 24, 2017 at 20:47

1 Answer 1

1

Your best bet is to break up messages into chunks and just request the messages you need at the time.

In order to quickly build a message list for display to the user, you might want to consider requesting ENVELOPE for all messages first. IMAP servers are generally optimised for this and the ENVELOPE response is much smaller than the RFC822 or BODY[TEXT] responses.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.