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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:08:37+00:00 2026-06-01T13:08:37+00:00

I am working on a mail client application which syncs emails for a GMail

  • 0

I am working on a mail client application which syncs emails for a GMail account using the IMAP c-client library.

How can I get the most recent unseen/unread e-mails in the mailbox without blindly searching for all unread e-mails?

A mail search needs to pull all unread e-mails on every sync to the client but it is quite an expensive operation to perform on every sync.
Is there a better aproach to communicate to the client any unread e-mails which were not sync’d on the previous interaction with the server?

Thunderbird, for example, is able to sync unseen e-mails with some mechanism (possibly by doing a blind search for all unseen e-mails) as the IDLE command won’t notify
the client about them.

Is there some mechanism that can tell the client about unread e-mails that have appeared since the last sync?

  • 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-06-01T13:08:39+00:00Added an answer on June 1, 2026 at 1:08 pm

    There is an IMAP extension for Quick Flag Changes Resynchronization (RFC-4551). With this extension it is possible to search for all messages that have been changed since the last synchronization (based on some kind of timestamp). However, this extension is not widely supported – in particular not by gmail’s IMAP server:

    * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE
    

    There is an informational RFC that describes how IMAP clients should do synchronization (RFC-4549, section 4.3). The text recommends the issuing the following two commands:

    tag1 UID FETCH <lastseenuid+1>:* <descriptors>
    tag2 UID FETCH 1:<lastseenuid> FLAGS
    

    The first command is used to fetch the required information for all unknown mails (without knowing how many mails there are). The second command is used to synchronize the flags for the already seen mails.

    This method is widely used. Therefore, many IMAP servers contain an optimization in order to provide this information quickly. Typically, the network bandwidth is the limiting factor.

    If you are only interested in the UNSEEN flag, a UID SEARCH is probably the best you can do.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a mail client Application for downloading gmail emails, which uses
I am working on an IMAP client using java mail. We currently have a
I'm working on a web-based application, and looking to integrate each user's e-mail (gmail,
Part of the application I'm working on for my client involves sending emails for
I'm working with a program that can send email supporting yahoo mail and gmail.
I am working on an imap email client. I have a search function, which
I am creating Email client using JavaMail API. Everything is working fine like I
I can't understand why this code is not working. I get an error saying
I am working on an email client application in C#. I want to display
I am working on project which needs to read .doc file given by client.

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.