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 6333259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:25:40+00:00 2026-05-24T18:25:40+00:00

I am trying to search and filter my imap mails using python’s imaplib. I

  • 0

I am trying to search and filter my imap mails using python’s imaplib. I am running into a quite strange problem with the search command, searching for email addresses in the FROM field. I have the following script,

print('search with name')
status, results = con.search(None, '(FROM "Shrikant Sharat")')
if status == 'OK':
    if results[0]:
        mid = results[0].split()[0]
        print('mail id', mid)
        print(con.fetch(mid, '(UID BODY[HEADER.FIELDS (FROM)])'))
    else:
        print('No results yielded')
else:
    print('unable to search', results)

print()
print('search with email')
status, results = con.search(None, '(FROM "shrikantsharat.k@gmail.com")')
if status == 'OK':
    if results[0]:
        mid = results[0].split()[0]
        print('mail id', mid)
        print(con.fetch(mid, '(UID BODY[HEADER.FIELDS (FROM)])'))
    else:
        print('No results yielded')
else:
    print('unable to search', results)

for which, I get the following result,

search with name
mail id 2155
('OK', [('2155 (UID 5340 BODY[HEADER.FIELDS (FROM)] {54}', 'From: Shrikant Sharat <shrikantsharat.k@gmail.com>\r\n\r\n'), ' FLAGS (\\Seen))'])

search with email
No results yielded

Why does the second search fail? The email address is present in the From field as shown by the previous search. The second search should’ve matched this mail right?

Is this not the way to search for email address in the From field? I am pulling my hair apart on this one. Any ideas?

Edit If relevant, I am trying this with an IMAP server exposed by MS Exchange (2007, I think).

  • 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-24T18:25:42+00:00Added an answer on May 24, 2026 at 6:25 pm

    use this as your filter:

    (HEADER FROM "shrikantsharat.k@gmail.com")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using hibernate search 3.4, and I'm running in to a small problem. I
I'm currently trying to build a filter search function using JQuery and Ajax. The
I am trying to filter/search a database with ajax $.ajax({ type: POST, url: filterSearch.php,
I am trying to dynamically filter search results. Every result has tags associated with
I'm trying to search using the windows search one of my web directories for
This is a bit urgent! I'm trying to make a simple filter search where-by
I've been reading on how to search LDAP servers using Python, but Ive been
I am trying to implement search functionality for a list using jQuery. I am
I am trying to provide a link to filter search results. <%= Html.ActionLink(Filter Results,
I am trying to make search on my database using Solr, and i need

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.