login about faq

This one is a challenge. Seems GMAIL allows for some damn crazy mailbox values, as such I've been working on properly escaping the string values used by Gmail.

Here's an example:


So we escape this properly (as per IMAP RFC):


And use ExamineMailbox..

It fails, so I pull the session log and see:

----IMAP REQUEST---- aaaq EXAMINE "AnyCharsWeCan&AFw-'tUse?!@#$%&-*()_+{}|[]&AFwAXA-;:&AFw-'&AFw-"" ----IMAP RESPONSE---- aaaq BAD Could not parse command

Any idea what is going on here?


Ok, I've done a lot more digging, here's what I've uncovered.

First I switched everything to the Unicode version, just to avoid any ANSI/Utf8 mis-calculations. Next, I opened up Thunderbird and dumped the entire IMAP traffic, I noticed it was issuing the following:

select "AnyCharsWeCan'tUse?!@#$%&-*()_+{}|[]\;:'""

The key there is the "dash" value. When I run the same command (SelectMailbox) using the unicode output of ListMailboxes I get the following in the Session Log.

SELECT "AnyCharsWeCan'tUse?!@#$%&*()_+{}|[]\;:'""

Notice the "-" is gone? GMAIL returns that this is an invalid UTf7 string..

So I go back to ListMailboxes and dump the Session log immediately upon completion.


  • LIST (HasNoChildren) "/" "AnyCharsWeCan'tUse?!@#$%&-*()_+{}|[]\;:'""

So I'm getting good values from the ListMailboxes, however I'm not getting that same value when I iterate through the CkMailboxesW object. Calling ->getName(i) gives me a wchar_t * that is missing the "-" value.

Any ideas?


asked Apr 10 '13 at 12:22

hazmat's gravatar image


edited Apr 10 '13 at 16:56

You shouldn't need to escape any chars in the mailbox name -- other than possibly escaping characters according to the syntax of a given programming language when it comes to literal strings. In the IMAP protocol, the mailbox names are encoded to utf-7 as per the IMAP protocol specification. (It's not exactly utf-7, because the IMAP protocol defines a few differences, and Chilkat adheres to the IMAP specifications.) Also, there should be no need to worry about ANSI/utf-8/Unicode. As long as you're passing the string correctly, then Chilkat automatically handles any necessary conversions (from ANSI, or utf-8, or Unicode) to the utf-7 required.


answered Apr 10 '13 at 18:30

chilkat's gravatar image

chilkat ♦♦

In other words, just pass the mailbox name as-is.

(Apr 10 '13 at 18:31) chilkat ♦♦

If there is still a problem, please post the following so that I can reproduce the problem:

1) A snippet of code that shows the mailbox name being passed to SelectMailbox as a literal string.

2) The contents of the LastErrorText after calling SelectMailbox

3) The contents of the SessionLog.

(Apr 10 '13 at 18:33) chilkat ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Apr 10 '13 at 12:22

Seen: 1,255 times

Last updated: Apr 10 '13 at 18:33

powered by OSQA