This project is read-only.

Not able to retrieve the inbox folder

Oct 15, 2013 at 12:16 AM

I'm having troubles with the imap server (993, using SSL).
I'm able to Connect.
Then, the cli.GetFolders() does not return any inbox folder. I just can see the Sent, Draft and Trash folder.
Even using the sample application, I see the Sent, Draft, Trash folder but not the Inbox folder.

Instead, by using the webmail site, I can see the inbox folder...

Any suggestion ?
Thanks in advance,
Oct 15, 2013 at 12:51 AM
By debugging, I've noticed that in GetFolders.cs, the

SendAndReceive(command, ref arrayList)

returns an item

arraylist[1] = "* LIST (\NoInferiors) NIL INBOX"

it seems that this item is not added to the Folders collection

is this correct ?
Oct 15, 2013 at 8:44 AM
Hi Francesco,

of course it is not correct to drop this folder and not add it the collection. The issue occurs because normally the server will return a valid folder delimeter and not NIL as in your case.

I updated the code in the repository, so you can test the fix right away. The binaries will be updated later today.

Kind regards,

Pavel Azanov
Oct 15, 2013 at 9:50 AM
Wow ! so I'll wait for your updates !

of course, you will win a donation :)

Oct 15, 2013 at 4:11 PM
Hi Pavel,

I've compiled the source code and obtained a new dll.
I've updated my project.

Now, I'm ONLY able to connect to the imap server. But I Always get cli.IsAuthenticated = false
So, no folders are returned by the Folders.

here is the code (VB.Net):
    Dim cli As ImapClient = New ImapX.ImapClient
    cli.UseSsl = usaSSL 
    cli.Credentials = New ImapX.Authentication.PlainCredentials(login, password)
    cli.SslProtocol = Security.Authentication.SslProtocols.Default

    cli.Port = imapPort  
    cli.Host = imapServer     
    Debug.Print(cli.IsConnected.ToString)    -> returns True
    Debug.Print(cli.IsAuthenticated.ToString)  -> returns False
    Debug.Print("Folders:" + cli.Folders.Count.ToString)    -> returns 0 folders (from several imap server, even Gmail)
where I'm wrong ?
Please, could you post the new binaries ?
Thanks a lot.

Oct 15, 2013 at 5:36 PM
Edited Oct 15, 2013 at 5:37 PM
Hi Francesco,

the Connect method only connects to the server, it does not authenticate the user. Remove this line from your code:
cli.Credentials = New ImapX.Authentication.PlainCredentials(login, password)
and, after a successful connection, simply make a call to Login:
If cli.Connect() Then
    If cli.Login(login, password)
         // Login successful
    End If
End If
I'll make another code update, so you can set the Credentials property manually, like you tried, and then call the Login method without parameters.


Oct 15, 2013 at 7:10 PM
The connection works ! I'm able to connect and get the folders collection as well as the INBOX folder :)
thank you

Now, next problem. I take the inbox messages:
    Dim myFolder As ImapX.Folder = cli.Folders.Inbox
    Dim myMessages As ImapX.MessageCollection = myFolder.messages
1) The myMessages collection has 188 items, but all messages appears to be empty
2) how do I take ONLY the UNSEEN messages collection ?

thank you
Oct 15, 2013 at 8:15 PM
You're welcome. To filter the messages, you can use the Folder.Search method:
Dim myMessages As ImapX.MessageCollection = myFolder.Search("UNSEEN", true)
Setting the second argument to true will download all found messages automatically.
If you want to do it manually, set the second argument of Search to false, and call the Process method on each returned message manually.

Also consider that the Folder.Search method as well as the Message.Process method are only available in ImapX I changed the message downloading process in the new version of the library and now writing documentation on how to request messages. As soon as I'm finished, I will publish the version


Oct 15, 2013 at 9:38 PM
Yeah ! It works :)

thank you Pavel.
I've done a small donation. Just a way to say thank you for your excellent job :)

Oct 16, 2013 at 9:37 AM
Thank you Francesco! I received the donation, is it alright if I mention your name on the Home tab together with other people supporting this project?

If you have more questions, feel free to ask.

Kind regards,

Oct 16, 2013 at 10:17 AM
of course !

it is a pleasure for me :)