Skip to main content

JavaMail 1.4.6-SNAPSHOT, Gmail getLabels problems

  1 post   Feedicon  
Replies: 0 - Last Post: January 29, 2013 13:03
by: Mark McLaren
showing 1 - 1 of 1
Posted: January 29, 2013 13:03 by Mark McLaren


I have been playing with the the experimental Gmail support in JavaMail 1.4.6-SNAPSHOT. I have been having problems using getLabels.

By turning debug on I can see that the X_GM_LABELS are being returned by the Gmail server. I have tracked the problem down to GmailProtocol using IMAPResponse's readSimpleList method to parse the labels string.

As far as I can tell the returned label values are not lists of simple strings. In my local implementation I added a method to IMAPResponse called "readAtomStringList" (code below) and tweaked GmailProtocol to use that instead of readSimpleList.. It seems to work!

It is great to see Gmail support in JavaMail,

Many thanks,


public String[] readAtomStringList() {

if (buffer[index] != '(') // not what we expected
    return null;
index++; // skip '('

Vector v = new Vector();
    String as;
do {
        as = readAtomString();
        if(as.length() > 0){
} while (buffer[index++] != ')');

int size = v.size();
if (size > 0) {
    String[] s = new String[size];
    return s;
} else  // empty list
    return null;    
Replies: 0 - Last Post: January 29, 2013 13:03
by: Mark McLaren
Please Confirm