0 votes

I have a corporate Google Apps account and am trying to access my IMAP folders. As the documentation states, the best practice is to use the CommonFolders class, because Google has localized names for all system folders. Unfortunately I can't get it to work. When using new CommonFolders(imap.GetFolders()) all system folder properties, like CommonFolders.Inbox or CommonFolders.AllMail contain the localized name. And when using these CommomFolders properties to select a specific system folder, I get an error saying the selected folder does not exist:

  • [NONEXISTENT] Unknown Mailbox: Postvak IN (Failure)
  • [NONEXISTENT] Unknown Mailbox: [gmail]/alle berichten (Failure)

These errors are to be expected, as the folders names should be:

  • Inbox
  • [Gmail]/All Mail

When selecting Inbox, I won;t get an error and the messages in that folder can be retrieved successfully. But when selecting [Gmail]/All Mail, I stil get an error:

  • [NONEXISTENT] Unknown Mailbox: [Gmail]/All Mail (Failure)

This is very strange, 'cause this should be the right name for the "All Mail" folder.

I also tried my personal Gmail account, but the same errors occur there. And when changing my Gmail display language from Dutch to English (US), the Inbox folder selection works, but all other folders return the [NONEXISTENT] Unknown Mailbox error.

What could be going wrong here?

by (200 points)

1 Answer

0 votes

When using new CommonFolders(imap.GetFolders()) all system folder properties, like CommonFolders.Inbox or CommonFolders.AllMail contain the localized name.

This is expected and correct behavior.

These errors are to be expected, as the folders names should be:
Inbox
[Gmail]/All Mail

No, localized names should be used. Only INBOX folder name should not be localized, as Google doesn't allow selecting INBOX folder by using its localized name. Mail.dll recognizes that and always uses "INBOX" name.

When selecting Inbox, I won;t get an error and the messages in that folder can be retrieved successfully. But when selecting [Gmail]/All Mail, I stil get an error

Localized names must be used for all folders except INBOX. Folder named 'All Mail' doesn't exists on the Gmail's IMAP server, if it uses a different language than English. Localized version of 'All Mail' is the only correct name.

Please turn on logging, use new CommonFolders(imap.GetFolders()) and try selecting AllMail and Inbox.

by (301k points)
edited by
You must use a localized name to select a folder!

For example:

C: 71f26035591743e1 XLIST "" "*"
S: * XLIST (\HasNoChildren \Inbox) "/" "Posteingang"
S: * XLIST (\Noselect \HasChildren) "/" "[Gmail]"
S: * XLIST (\AllMail \HasNoChildren) "/" "[Gmail]/Alle Nachrichten"
S: * XLIST (\Drafts \HasNoChildren) "/" "[Gmail]/Entw&APw-rfe"
S: * XLIST (\Sent \HasNoChildren) "/" "[Gmail]/Gesendet"
S: * XLIST (\Starred \HasNoChildren) "/" "[Gmail]/Markiert"
S: * XLIST (\HasNoChildren \Trash) "/" "[Gmail]/Papierkorb"
S: * XLIST (\Spam \HasNoChildren) "/" "[Gmail]/Spam"
S: * XLIST (\Important \HasNoChildren) "/" "[Gmail]/Wichtig"
S: 71f26035591743e1 OK Success
C: 7c85757af7b44096 SELECT "[Gmail]/Alle Nachrichten"
S: * FLAGS (\Answered ...
S: * OK [PERMANENTFLAGS ...
S: * OK [UIDVALIDITY 627130625] UIDs valid.
S: * 0 EXISTS
S: * 0 RECENT
S: * OK [UIDNEXT 26242] Predicted next UID.
S: * OK [HIGHESTMODSEQ 1009036]
S: 7c85757af7b44096 OK [READ-WRITE] [Gmail]/Alle Nachrichten selected. (Success)
But I AM using the localized name: [gmail]/alle berichten. This is the value returned by both the FolderInfo.Name property and the FolderInfo.GetImapName() method. But when using this string value when calling Imap.Select, so Imap.Select("[gmail]/alle berichten"), I get the non existent error.
This is why I already told you, that your problem is with url encoding utf8 characters, and also asked for the logs.
Using another form of encoding indeed solved my problem. Thanks. Just one more question: the FolderInfo class has the GetImapName method, but the FolderStatus class does not. Is there any way to find out the ImapName for a FolderStatus class? Or might the GetImapName method be added to this class in the near future?
FoldersStatus class contains Name property only.
...