+1 vote

Is it possible to get information about folder type (e.g. is it Spam, Deleted Items, Draft etc. if our exchange server does not support XLIST and SPECIAL-USE extensions.

If it is possible please provide me sample of code.

by

1 Answer

0 votes

Well it is simply not possible, as those information is not returned by the IMAP server.

Mail.dll IMAP library recognizes folders by XLIST and SPECIAL-USE flags. It also tries to match folders using commonly used names. However if the IMAP server uses national names, this will fail.

Here's the code to obtain IMAP folders by purpose:

using (Imap imap = new Imap())
{
    imap.ConnectSSL("imap.example.com");
    imap.UseBestLogin("user@example.com", "password");

    CommonFolders folders = new CommonFolders(imap.GetFolders());

    Console.WriteLine("Inbox folder: " + folders.Inbox.Name);
    Console.WriteLine("Sent folder: " + folders.Sent.Name);
    Console.WriteLine("Spam folder: " + folders.Spam.Name);

    imap.Close();
}
by (301k points)
...