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

  • Home
  • SEARCH
  • 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 7969123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:11:16+00:00 2026-06-04T07:11:16+00:00

I have an imap account, (e.g. some@gmail.com) and I know many libraries with which

  • 0

I have an imap account, (e.g. some@gmail.com) and I know many libraries with which I can connect and replicate messages back to my destination. I want to achieve following,

  1. First time, I want to download all messages (including sent folders), and when I download for the first time, I will save message with ID and UID locally in some database.
  2. Second time, I do not want to query downloaded messages, even though their read/unread status or any flag or deleted flag is changed or they are purged.
  3. Our aim is to download and sync every messages locally, once and only first time.

Now I know little about IMAP message that they have something called ID, UID and MessageID. ID is probably an offset in current folder, UID is numeric id in current account and MessageID is a unique string.

Now I want to know, what search I should use while querying folder, so that messages once downloaded, wont be returned back to me.

I am planning to use http://mailsystem.codeplex.com/ library, and it gives ability to Search with custom string and returns int array.

Assuming I have, a MaxID, and I want to only download messages which has ID or UID greater than MaxID. Which one should I use? UID or ID?

  • 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-04T07:11:16+00:00Added an answer on June 4, 2026 at 7:11 am

    You should use the UID in combination with UIDVALIDITY. Both values are folder specific.

    There is an informational RFC that describes how IMAP clients should do synchronization (RFC-4549, section 4.3). The text recommends 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.

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

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

Sidebar

Related Questions

I have tested PHP's IMAP lib. to fetch emails from a GMAIL account, but
Does anyone know a way to read email messages from a gmail account in
I have wrote a simple php script which reads an IMAP email account and
i have to create a simple script which retrieves the mails from gmail account
Hy, I am retrieving mails from a gmail account programaticaly using this libraries http://mailsystem.codeplex.com/
I have to read Gmail's imap mail with a Python script with Django, and
I'm acquiring the unread mails I have in my GMail account through PHP and
I'm building a little script that will connect to an IMAP account and grab
Say my gmail account gets an email, how can I make it so that
I have a webapp where users can create their account and use the service.

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.