0 votes

I am working on an application where I download all IMAP folders and their emails at first.
Then I run a scheduled task to check for new emails (using largest UID method) every few minutes for each folders of an Email address account. I select folder using:

imap.Select(folderName);

Folder name is taken from list of folders I have stored in my database. But if folder has been renamed from some other applications in Imap server, then I cannot select that folder and I run into trouble.

So, I would like to know if there is any method to know if a folder has been renamed or its old name is still stored some where. I cannot find any folder Id or Unique identifier for Imap folders. Please help.

I hope my question is clear enough to understand.
Thanks.

by (1.2k points)

1 Answer

0 votes

There is no way to know if the folder was renamed. At least I don't know about it.

You may try (but this is probably very server dependent) to check FolderStatus.UIDValidity of all other folders, but again this property is for some other purposes.

FolderStatus.UIDValidity - Gets the unique identifier validity value.
Any change of unique identifiers between sessions MUST be detectable
using the change of UIDVALIDITY. If unique identifiers from an earlier
session fail to persist in this session, the UIDVALIDITY value MUST be
greater than the one used in the earlier session.

by (300k points)
Thanks for the such quick response.
But what about identifiers for folders.
Is there not even a single unique identifier for Imap folders?
I know that Folder name is unique within its root. But it can be changed and i also found that change in root folder's name changes folder name of its children. Am I missing some thing?
There is no such id in IMAP protocol.
...