Search code examples
javadirectoryjakarta-mailimap

IMAP: java, how to determine a folder has been renamed or moved?


We use java mail api with an imap account. Suppose we have an empty folder a and then rename it to b on outlook. The folder has fullname inbox.a and then inbox.b. Or we move the folder to inbox.c for example, it becomes inbox.c.a.

How can we determine for example rename action (a to b), more clearly how can be distinguish:

  1. a was renamed to b or
  2. a was deleted and totally different folder b was generated

Do we have to use the messages in the folders to help whether it was a real rename or delete/create action?

In java, when i debug IMAPFolder instance, the only value i can keep reference is the UIDValidty number? Can i rely on it? As i know it can be changed by the mail server on some occurances.


Solution

  • There isn't a standard way. Some servers have a non-standard extension to relieve that (status x-guid), but gmail is the world's biggest IMAP server and does not implement x-guid.

    This is a problem. Fortunately it doesn't happen very often.

    Two different, independent mailboxes can have the same uidvalidity. I don't know how commonly that happens.