+1 vote


I'm currently looking to try and retrieve a Boolean value for subfolders inside the inbox. What I'm trying to do is have the program we have look at the date of the email and, if a folder does not exist for that date, create one and if it does exist then it will skip over the line of code that creates the folder.

Below is an attempt at trying to find out whether the folder exists but unfortunately it returns an error where value type 'Folderinfo' cannot be converted to 'Boolean'

Dim all As List(Of FolderInfo) = client.GetFolders()
Dim exists As Boolean = all.Find(
    Function(test) test.CanSelect = "INBOX/Test folder")
by (461 points)

1 Answer

+1 vote
Best answer

FolderInfo.CanSelect property gets the value indicating if you can select this folder for example using Imap.Select method. It searches for \NoSelect or \NonExistent flag. Some folders may exist, but are not selectable.

To check if folder with specified name exists on the server - use Imap.GetFolders method:

Dim all As List(Of FolderInfo) = imap.GetFolders()
Dim exists As Boolean = all.Exists(Function(x) x.Name = "INBOX")
by (298k points)
selected by


Thanks for that, exactly what I was looking for! Think I'd gotten myself a bit turned around...