Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1028343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:22:23+00:00 2026-05-16T12:22:23+00:00

The examples I’ve seen about loading emails over IMAP using python do a search

  • 0

The examples I’ve seen about loading emails over IMAP using python do a search and then for each message id in the results, do a query. I want to speed things up by fetching them all at once.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:22:23+00:00Added an answer on May 16, 2026 at 12:22 pm

    RFC 3501 says fetch takes a sequence set, but I didn’t see a definition for that and the example uses a range form (2:4 = messages 2, 3, and 4). I figured out that a comma separated list of ids works. In python with imaplib, I’ve got something like:

        status, email_ids = con.search(None, query)
        if status != 'OK':
            raise Exception("Error running imap search for spinvox messages: "
                            "%s" % status)
    
        fetch_ids = ','.join(email_ids[0].split())
        status, data = con.fetch(fetch_ids, '(RFC822.HEADER BODY.PEEK[1])')
        if status != 'OK':
            raise Exception("Error running imap fetch for spinvox message: "
                            "%s" % status)
        for i in range(len(email_ids[0].split())):
            header_msg = email.message_from_string(data[i * 3 + 0][1])
            subject = header_msg['Subject'],
            date = header_msg['Date'],
            body = data[i * 3 + 1][1] # includes some mime multipart junk
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

VB examples please I need to return the same results from linq as I
The examples for JNI i've seen map Java native methods to implementation by C++
The examples of functional dependencies I've seen boil down to mapping container -> element
Many examples I've seen don't explicitly call connect() . Instead they just use getInputStream()
I am reading a book about Javascript and jQuery and using one of the
Examples I have seen .properties files with a convention similar to the following: Example
In examples I have seen of UINavigationContoller and UITableView , switching to next view
Most examples I see about hosting WCF in IIS have you create an Application
Most examples I've seen have scripts in a html page being enclosed by <!--
From examples I've seen COM IUnknown::Release() function implementation is something like that: ULONG Release()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.