What is the difference between a message ID and a unique ID?

Dear team,

I wonder what the difference is between messageId and uniqueId.

Also, there are 10,000 emails in the inbox, but I’ve got more than 10,000 emails. (Gmail)

Is this related to the messageId and uniqueId?

client.selectFolder("inbox");
ImapQueryBuilder builder = new ImapQueryBuilder(StandardCharsets.UTF_8);
builder.getSentDate().since...
builder.getSentDate().beforeOrEqual...
MailQuery query = builder.getQuery();
client.listMessages(query);

Hello @Goran_Zhou ,

It’s been a while since we saw you here last. Let me answer your question:

Both MessageId and UniqueId are unique message identifiers.

  • MessageId is generated by the client program sending the message. MessageId is added as a header to the MIME message.
  • UniqueId is the ID of the message in the IMAP folder. This ID is assigned by the IMAP server to each mail in the folder and is used to search and retrieve a particular mail via the IMAP protocol.

For example, if you copy the same email into a folder twice, each email will have the same MessageId in the header, but a different UniqueId.

Therefore, it is always better to use the UniqueId to search and retrieve the message.

Thanks for your interest to our product.