0 votes
by (520 points)


when trying to create a new folder on an IMAPv4 server, I'm getting the following exception:


Client tried to access nonexistent namespace. (Mailbox name should probably be prefixed with: INBOX.)


await imap.CreateFolderAsync("Drafts");

While I do know that replacing "Drafts" with "INBOX.Drafts" would work, I'd assume I could query the server for this information before the exception is being thrown.

My investigation revealed that this might be the "Root folder path" Outlook sometimes needs to set, but it'd be bogus work to try and catch an exception every time I'm trying to create a folder due to the variety of my customer base (and therefore a variety of e-mail servers).

Applies to: Rebex Secure Mail

1 Answer

0 votes
by (58.9k points)

The IMAP protocol is quite tricky when it comes to folders.

So when working with IMAP clients we recommend first to change into the compulsory "INBOX" folder. This way you will prevent the exception you reported "Client tried to access nonexistent namespace. (Mailbox name should probably be prefixed with: INBOX.)". I have tested this approach with Gmail, Yahoo and Exchange IMAP server and they all enabled me to create a custom folder after selecting the Inbox folder first:

        Imap imap = new Imap();

        imap.Connect("imap.mail.yahoo.com", SslMode.Implicit);
        imap.Login("username", "password");


        if (!imap.FolderExists("MyFolder"))

by (520 points)

Thank you for your answer. Unfortunately, this does not work. I've tested this with the german "Alfahosting.de" and the only mitigation is when not creating "MyFolder" but "INBOX.MyFolder" instead... But that's not what I want and a try-catch workaround is unwanted.

by (58.9k points)

If that IMAP server really behaves like this, then it is bad server behavior and unfortunately we cannot fix it from client point-of-view. To make sure that this is a server issue you could create the log from the Rebex IMAP client and either post it here or send it to support@rebex.net.

If you are sure that although you selected the "INBOX" folder first, still you are unable to create the "MyFolder" folder without the "INBOX." prefix provided, then we recommend to report it to the IMAP server vendor as a bug and ask them what to do.