|
View:
New views
10 Messages
—
Rating Filter:
Alert me
|
|
|
JavaMail IMAPFolder search commandHi there!
I'm quite new to the list and therefore I don't know if I'm in the correct place. I hope so. :) Actually I'm trying to issue a SEARCH command (through f.search where f is an object of IMAPFolder) to an Exchange server. The task is to search out 3 mails (on the basis of the Message-Id in the header). Therefore, I'm constructing a SearchTerm-object. As far as I understood, I have to construct it like a tree. My tree is looking similar to this one: OrTerm | | HeaderTerm OrTerm | | HeaderTerm HeaderTerm If I'm issueing that command, the server returns 0 elements. If I issue the HeaderTerms seperately I get the desired elements. So, what I'm doing wrong? Must the mail server have some capabilities to perform searches with a higher depth than 1? Thanks for your help. Kind regards, Wolfgang P.S: I'm working with JavaMail version 1.4.1. =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
R: JavaMail IMAPFolder search commandHi,
You can enable debug in javamail and see what's the difference between the 2 imap search commands you run. The SEARCH command is part of IMAPv4 spec, I don't think you need any special capabilities on your server. Bye, Paolo -----Messaggio originale----- Da: A mailing list for discussion of the JavaMail(tm) API [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher Inviato: martedì 27 gennaio 2009 15.58 A: JAVAMAIL-INTEREST@... Oggetto: JavaMail IMAPFolder search command Hi there! I'm quite new to the list and therefore I don't know if I'm in the correct place. I hope so. :) Actually I'm trying to issue a SEARCH command (through f.search where f is an object of IMAPFolder) to an Exchange server. The task is to search out 3 mails (on the basis of the Message-Id in the header). Therefore, I'm constructing a SearchTerm-object. As far as I understood, I have to construct it like a tree. My tree is looking similar to this one: OrTerm | | HeaderTerm OrTerm | | HeaderTerm HeaderTerm If I'm issueing that command, the server returns 0 elements. If I issue the HeaderTerms seperately I get the desired elements. So, what I'm doing wrong? Must the mail server have some capabilities to perform searches with a higher depth than 1? Thanks for your help. Kind regards, Wolfgang P.S: I'm working with JavaMail version 1.4.1. =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: R: JavaMail IMAPFolder search commandYou can also simplify your expression by using a single OrTerm with
three HeaderTerms, although it shouldn't make a difference. The debug output should help figure out what's going on. Paolo Spadafora wrote: > Hi, > You can enable debug in javamail and see what's the difference between the 2 > imap search commands you run. > The SEARCH command is part of IMAPv4 spec, I don't think you need any > special capabilities on your server. > > Bye, > Paolo > > > > -----Messaggio originale----- > Da: A mailing list for discussion of the JavaMail(tm) API > [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher > Inviato: martedì 27 gennaio 2009 15.58 > A: JAVAMAIL-INTEREST@... > Oggetto: JavaMail IMAPFolder search command > > Hi there! > > I'm quite new to the list and therefore I don't know if I'm in the > correct place. I hope so. :) > > Actually I'm trying to issue a SEARCH command (through f.search where f > is an object of IMAPFolder) to an Exchange server. The task is to search > out 3 mails (on the basis of the Message-Id in the header). Therefore, > I'm constructing a SearchTerm-object. As far as I understood, I have to > construct it like a tree. My tree is looking similar to this one: > > OrTerm > | | > HeaderTerm OrTerm > | | > HeaderTerm HeaderTerm > > If I'm issueing that command, the server returns 0 elements. If I issue > the HeaderTerms seperately I get the desired elements. > > So, what I'm doing wrong? Must the mail server have some capabilities to > perform searches with a higher depth than 1? > > Thanks for your help. > > Kind regards, > Wolfgang > > P.S: I'm working with JavaMail version 1.4.1. > > =========================================================================== > To unsubscribe, send email to listserv@... and include in the body > of the message "signoff JAVAMAIL-INTEREST". For general help, send email to > listserv@... and include in the body of the message "help". > > =========================================================================== > To unsubscribe, send email to listserv@... and include in the body > of the message "signoff JAVAMAIL-INTEREST". For general help, send email to > listserv@... and include in the body of the message "help". =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
|
|
|
R: R: JavaMail IMAPFolder search commandCheck to see if it happens only for headerterm or any other term search.
Try with the same code but use flagterm or another term class and use simple values, avoid special chars, let's see what happens. Bye. Paolo -----Messaggio originale----- Da: A mailing list for discussion of the JavaMail(tm) API [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher Inviato: mercoledì 28 gennaio 2009 14.51 A: JAVAMAIL-INTEREST@... Oggetto: Re: R: JavaMail IMAPFolder search command Yes, I know. I tried also that variant but with no success. This is the debug output I get from javaMail when issueing the command: A6 SEARCH OR OR HEADER Message-ID mailman.0.1233063092.30210.devel@... HEADER Message-ID rt-3.4.5-16942-1232966693-1122.46544-5-0@... HEADER Message-ID 1233063449.7818.12.camel@... ALL * SEARCH A6 OK SEARCH completed. This is the debug output when I try to search with 2 terms connected through a OrTerm: A6 SEARCH OR HEADER Message-ID mailman.0.1233063092.30210.devel@... HEADER Message-ID rt-3.4.5-16942-1232966693-1122.46544-5-0@... ALL * SEARCH 66 72 A6 OK SEARCH completed. You can clearly see, that in the second example there will be returned 2 mail items (66, 72). This is my code which returns such results. Maybe I didn't understand how to use the SearchTerm-constructs: [...] IMAPFolder f = (IMAPFolder) eStore.getDefaultFolder().getFolder("inbox"); f.open(Folder.READ_ONLY); SearchTerm a = new HeaderTerm(Def.HEADER_MESSAGE_ID, "mailman.0.1233063092.30210.devel@..."); SearchTerm b = new HeaderTerm(Def.HEADER_MESSAGE_ID, "rt-3.4.5-16942-1232966693-1122.46544-5-0@..."); SearchTerm c = new OrTerm(a, b); SearchTerm d = new HeaderTerm(Def.HEADER_MESSAGE_ID, "1233063449.7818.12.camel@..."); SearchTerm g = new OrTerm(new SearchTerm[] {a, b, d}); Message[] ms = f.search(c); [...] As a side note: I'm using an Exchange 2003 server for my tests. I tried also to use another server (Zimbra server) and there it is working. So, only the Exchange server returns such strange results. The login procedure produces the following debug output. Maybe does it make sense for you... * OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 (myServer.org) ready. A0 CAPABILITY * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN A0 OK CAPABILITY completed. DEBUG: protocolConnect login, host=myFancyHost.org, user=myUsername, password=<non-null> A1 LOGIN myUsername myPassword A1 OK LOGIN completed. A2 CAPABILITY * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS NAMESPACE LITERAL+ UIDPLUS CHILDREN A2 OK CAPABILITY completed. DEBUG: setDebug: JavaMail version 1.4.1 DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc] DEBUG: mail.imap.fetchsize: 16384 Thanks for your help. Kind regards, Wolfgang On Tue, 2009-01-27 at 10:16 -0800, Bill Shannon wrote: > You can also simplify your expression by using a single OrTerm with > three HeaderTerms, although it shouldn't make a difference. > > The debug output should help figure out what's going on. > > Paolo Spadafora wrote: > > Hi, > > You can enable debug in javamail and see what's the difference between the 2 > > imap search commands you run. > > The SEARCH command is part of IMAPv4 spec, I don't think you need any > > special capabilities on your server. > > > > Bye, > > Paolo > > > > > > > > -----Messaggio originale----- > > Da: A mailing list for discussion of the JavaMail(tm) API > > [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang > > Inviato: martedì 27 gennaio 2009 15.58 > > A: JAVAMAIL-INTEREST@... > > Oggetto: JavaMail IMAPFolder search command > > > > Hi there! > > > > I'm quite new to the list and therefore I don't know if I'm in the > > correct place. I hope so. :) > > > > Actually I'm trying to issue a SEARCH command (through f.search > > is an object of IMAPFolder) to an Exchange server. The task is to search > > out 3 mails (on the basis of the Message-Id in the header). Therefore, > > I'm constructing a SearchTerm-object. As far as I understood, I have to > > construct it like a tree. My tree is looking similar to this one: > > > > OrTerm > > | | > > HeaderTerm OrTerm > > | | > > HeaderTerm HeaderTerm > > > > If I'm issueing that command, the server returns 0 elements. If I issue > > the HeaderTerms seperately I get the desired elements. > > > > So, what I'm doing wrong? Must the mail server have some capabilities to > > perform searches with a higher depth than 1? > > > > Thanks for your help. > > > > Kind regards, > > Wolfgang > > > > P.S: I'm working with JavaMail version 1.4.1. > > > > > > To unsubscribe, send email to listserv@... and include in the body > > of the message "signoff JAVAMAIL-INTEREST". For general help, send email to > > listserv@... and include in the body of the message "help". > > > > =========================================================================== > > To unsubscribe, send email to listserv@... and include in the body > > of the message "signoff JAVAMAIL-INTEREST". For general help, send email to > > listserv@... and include in the body of the message "help". > > =========================================================================== > To unsubscribe, send email to listserv@... and include in the body > of the message "signoff JAVAMAIL-INTEREST". For general help, send email to > listserv@... and include in the body of the message "help". -- Wolfgang Beikircher Center for Applied Software Engineering (CASE) Free University of Bozen/Bolzano Mustergasse/Via della Mostra 4 39100 Bozen/Bolzano Italy =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: R: R: JavaMail IMAPFolder search commandOkay, I tried it now with the 'FlagTerm'. I search of emails with the
following flags: UNSEEN, ANSWERED, UNDELETED. All of these flags are connected through OR. I expect as a result all mails of the folder because no one is marked as deleted. Situation in my folder: 11 mails are marked as ANSWERED, 0 mails are marked as DELETED, and 90 mails are marked as SEEN. If I executed the search command only with the UNDELETED flag, I got the correct result (reference to all mails). The search command in connection with both other terms, I got the empty set. Just for curiosity, I tried to mark some mails (3 mails) as UNSEEN. Therefore, each search command issued alone would return some result set. To my surprise I got exactly these mails which I marked as UNSEEN. It seems to me, that Exchange looks only to the last 2 terms in the search command. Therefore I tried to switch the single search terms and... boom... I got another result. My conclusion is, that Exchange searches only for the last 2 terms in the OR conjunction. Do you agree on that? Or is it on the side of JavaMail (maybe the command must be put somehow in brackets)? Here is the list of commands issued to the server: 1. case: 11 mails ANSWERED, 0 mails DELETED, 0 mails UNSEEN A6 SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL * SEARCH A6 OK SEARCH completed. 2. case: 11 mails ANSWERED, 0 mails DELETED, 3 mails UNSEEN A6 SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL * SEARCH 87 88 89 A6 OK SEARCH completed. 3. case: 11 mails ANSWERED, 0 mails DELETED, 3 mails UNSEEN (switch ordering of search terms) A6 SEARCH OR OR (UNSEEN) (ANSWERED) (UNDELETED) ALL * SEARCH 22 24 26 36 38 50 61 62 65 68 74 A6 OK SEARCH completed. On Wed, 2009-01-28 at 18:02 +0100, Paolo Spadafora wrote: > Check to see if it happens only for headerterm or any other term search. > Try with the same code but use flagterm or another term class and use simple values, avoid special chars, let's see what happens. > > Bye. > > Paolo > > > -----Messaggio originale----- > Da: A mailing list for discussion of the JavaMail(tm) API [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher > Inviato: mercoledì 28 gennaio 2009 14.51 > A: JAVAMAIL-INTEREST@... > Oggetto: Re: R: JavaMail IMAPFolder search command > > Yes, I know. I tried also that variant but with no success. > > This is the debug output I get from javaMail when issueing the command: > A6 SEARCH OR OR HEADER Message-ID > mailman.0.1233063092.30210.devel@... HEADER Message-ID > rt-3.4.5-16942-1232966693-1122.46544-5-0@... HEADER Message-ID > 1233063449.7818.12.camel@... ALL > * SEARCH > A6 OK SEARCH completed. > > This is the debug output when I try to search with 2 terms connected > through a OrTerm: > A6 SEARCH OR HEADER Message-ID > mailman.0.1233063092.30210.devel@... HEADER Message-ID > rt-3.4.5-16942-1232966693-1122.46544-5-0@... ALL > * SEARCH 66 72 > A6 OK SEARCH completed. > > You can clearly see, that in the second example there will be returned 2 > mail items (66, 72). > > This is my code which returns such results. Maybe I didn't understand > how to use the SearchTerm-constructs: > [...] > > IMAPFolder f = (IMAPFolder) > eStore.getDefaultFolder().getFolder("inbox"); > > > f.open(Folder.READ_ONLY); > > SearchTerm a = new HeaderTerm(Def.HEADER_MESSAGE_ID, > "mailman.0.1233063092.30210.devel@..."); > SearchTerm b = new HeaderTerm(Def.HEADER_MESSAGE_ID, > "rt-3.4.5-16942-1232966693-1122.46544-5-0@..."); > SearchTerm c = new OrTerm(a, b); > SearchTerm d = new HeaderTerm(Def.HEADER_MESSAGE_ID, > "1233063449.7818.12.camel@..."); > SearchTerm g = new OrTerm(new SearchTerm[] {a, b, d}); > > Message[] ms = f.search(c); > > [...] > > As a side note: I'm using an Exchange 2003 server for my tests. I tried > also to use another server (Zimbra server) and there it is working. So, > only the Exchange server returns such strange results. The login > procedure produces the following debug output. Maybe does it make sense > for you... > > * OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 > (myServer.org) ready. > A0 CAPABILITY > * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS > NAMESPACE LITERAL+ UIDPLUS CHILDREN > A0 OK CAPABILITY completed. > DEBUG: protocolConnect login, host=myFancyHost.org, user=myUsername, > password=<non-null> > A1 LOGIN myUsername myPassword > A1 OK LOGIN completed. > A2 CAPABILITY > * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS > NAMESPACE LITERAL+ UIDPLUS CHILDREN > A2 OK CAPABILITY completed. > DEBUG: setDebug: JavaMail version 1.4.1 > DEBUG: getProvider() returning > javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun > Microsystems, Inc] > DEBUG: mail.imap.fetchsize: 16384 > > Thanks for your help. > > Kind regards, > Wolfgang > > On Tue, 2009-01-27 at 10:16 -0800, Bill Shannon wrote: > > You can also simplify your expression by using a single OrTerm with > > three HeaderTerms, although it shouldn't make a difference. > > > > The debug output should help figure out what's going on. > > > > Paolo Spadafora wrote: > > > Hi, > > > You can enable debug in javamail and see what's the difference > between the 2 > > > imap search commands you run. > > > The SEARCH command is part of IMAPv4 spec, I don't think you need > any > > > special capabilities on your server. > > > > > > Bye, > > > Paolo > > > > > > > > > > > > -----Messaggio originale----- > > > Da: A mailing list for discussion of the JavaMail(tm) API > > > [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang > Beikircher > > > Inviato: martedì 27 gennaio 2009 15.58 > > > A: JAVAMAIL-INTEREST@... > > > Oggetto: JavaMail IMAPFolder search command > > > > > > Hi there! > > > > > > I'm quite new to the list and therefore I don't know if I'm in the > > > correct place. I hope so. :) > > > > > > Actually I'm trying to issue a SEARCH command (through f.search > where f > > > is an object of IMAPFolder) to an Exchange server. The task is to > search > > > out 3 mails (on the basis of the Message-Id in the header). > Therefore, > > > I'm constructing a SearchTerm-object. As far as I understood, I have > to > > > construct it like a tree. My tree is looking similar to this one: > > > > > > OrTerm > > > | | > > > HeaderTerm OrTerm > > > | | > > > HeaderTerm HeaderTerm > > > > > > If I'm issueing that command, the server returns 0 elements. If I > issue > > > the HeaderTerms seperately I get the desired elements. > > > > > > So, what I'm doing wrong? Must the mail server have some > capabilities to > > > perform searches with a higher depth than 1? > > > > > > Thanks for your help. > > > > > > Kind regards, > > > Wolfgang > > > > > > P.S: I'm working with JavaMail version 1.4.1. > > > > > > > =========================================================================== > > > To unsubscribe, send email to listserv@... and include in > the body > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > email to > > > listserv@... and include in the body of the message "help". > > > > > > > =========================================================================== > > > To unsubscribe, send email to listserv@... and include in > the body > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > email to > > > listserv@... and include in the body of the message "help". > > > > > =========================================================================== > > To unsubscribe, send email to listserv@... and include in the > body > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > email to > > listserv@... and include in the body of the message "help". Wolfgang Beikircher Center for Applied Software Engineering (CASE) Free University of Bozen/Bolzano Mustergasse/Via della Mostra 4 39100 Bozen/Bolzano Italy =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
R: R: R: JavaMail IMAPFolder search commandIs the debug output of the search command you run on Zimbra the same?
I mean this: SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL Imap Spec doesn't say much, just OR <expr1> <expr2> Try writing a custom command like this(1): SEARCH OR (ANSWERED) ( OR (UNSEEN) (UNDELETED) ) ALL Something like this (didn't test it!): public class TestOrCommand implements IMAPFolder.ProtocolCommand { public Object doCommand(IMAPProtocol protocol) throws ProtocolException{ Argument args = new Argument(); args.writeString("ALL"); Response[] r = protocol.command("SEARCH OR (ANSWERED) ( OR (UNSEEN) (UNDELETED) ) ", args); //check the output, has to be as (1) Response response = r[r.length - 1]; // Grab all SORT responses if (response.isOK()) { // command successful for (int i = 0, len = r.length; i < len; i++) { if (!(r[i] instanceof IMAPResponse)) continue; IMAPResponse ir = (IMAPResponse) r[i]; if (ir.keyEquals("SEARCH")) { String num; while ((num = ir.readAtomString()) != null) { System.out.print(num+" "); } } } } protocol.notifyResponseHandlers(r); protocol.handleResult(response); return null; //just a test, don't need a return value } } TestOrCommand com = new TestOrCommand(); folder.open(Folder.READ_ONLY); folder.doCommand(com); And see how it goes. Paolo -----Messaggio originale----- Da: A mailing list for discussion of the JavaMail(tm) API [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher Inviato: giovedì 29 gennaio 2009 9.25 A: JAVAMAIL-INTEREST@... Oggetto: Re: R: R: JavaMail IMAPFolder search command Okay, I tried it now with the 'FlagTerm'. I search of emails with the following flags: UNSEEN, ANSWERED, UNDELETED. All of these flags are connected through OR. I expect as a result all mails of the folder because no one is marked as deleted. Situation in my folder: 11 mails are marked as ANSWERED, 0 mails are marked as DELETED, and 90 mails are marked as SEEN. If I executed the search command only with the UNDELETED flag, I got the correct result (reference to all mails). The search command in connection with both other terms, I got the empty set. Just for curiosity, I tried to mark some mails (3 mails) as UNSEEN. Therefore, each search command issued alone would return some result set. To my surprise I got exactly these mails which I marked as UNSEEN. It seems to me, that Exchange looks only to the last 2 terms in the search command. Therefore I tried to switch the single search terms and... boom... I got another result. My conclusion is, that Exchange searches only for the last 2 terms in the OR conjunction. Do you agree on that? Or is it on the side of JavaMail (maybe the command must be put somehow in brackets)? Here is the list of commands issued to the server: 1. case: 11 mails ANSWERED, 0 mails DELETED, 0 mails UNSEEN A6 SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL * SEARCH A6 OK SEARCH completed. 2. case: 11 mails ANSWERED, 0 mails DELETED, 3 mails UNSEEN A6 SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL * SEARCH 87 88 89 A6 OK SEARCH completed. 3. case: 11 mails ANSWERED, 0 mails DELETED, 3 mails UNSEEN (switch ordering of search terms) A6 SEARCH OR OR (UNSEEN) (ANSWERED) (UNDELETED) ALL * SEARCH 22 24 26 36 38 50 61 62 65 68 74 A6 OK SEARCH completed. On Wed, 2009-01-28 at 18:02 +0100, Paolo Spadafora wrote: > Check to see if it happens only for headerterm or any other term search. > Try with the same code but use flagterm or another term class and use simple values, avoid special chars, let's see what happens. > > Bye. > > Paolo > > > -----Messaggio originale----- > Da: A mailing list for discussion of the JavaMail(tm) API [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher > Inviato: mercoledì 28 gennaio 2009 14.51 > A: JAVAMAIL-INTEREST@... > Oggetto: Re: R: JavaMail IMAPFolder search command > > Yes, I know. I tried also that variant but with no success. > > This is the debug output I get from javaMail when issueing the command: > A6 SEARCH OR OR HEADER Message-ID > mailman.0.1233063092.30210.devel@... HEADER Message-ID > rt-3.4.5-16942-1232966693-1122.46544-5-0@... HEADER Message-ID > 1233063449.7818.12.camel@... ALL > * SEARCH > A6 OK SEARCH completed. > > This is the debug output when I try to search with 2 terms connected > through a OrTerm: > A6 SEARCH OR HEADER Message-ID > mailman.0.1233063092.30210.devel@... HEADER Message-ID > rt-3.4.5-16942-1232966693-1122.46544-5-0@... ALL > * SEARCH 66 72 > A6 OK SEARCH completed. > > You can clearly see, that in the second example there will be returned 2 > mail items (66, 72). > > This is my code which returns such results. Maybe I didn't understand > how to use the SearchTerm-constructs: > [...] > > IMAPFolder f = (IMAPFolder) > eStore.getDefaultFolder().getFolder("inbox"); > > > f.open(Folder.READ_ONLY); > > SearchTerm a = new HeaderTerm(Def.HEADER_MESSAGE_ID, > "mailman.0.1233063092.30210.devel@..."); > SearchTerm b = new HeaderTerm(Def.HEADER_MESSAGE_ID, > "rt-3.4.5-16942-1232966693-1122.46544-5-0@..."); > SearchTerm c = new OrTerm(a, b); > SearchTerm d = new HeaderTerm(Def.HEADER_MESSAGE_ID, > "1233063449.7818.12.camel@..."); > SearchTerm g = new OrTerm(new SearchTerm[] {a, b, d}); > > Message[] ms = f.search(c); > > [...] > > As a side note: I'm using an Exchange 2003 server for my tests. I tried > also to use another server (Zimbra server) and there it is working. So, > only the Exchange server returns such strange results. The login > procedure produces the following debug output. Maybe does it make sense > for you... > > * OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 > (myServer.org) ready. > A0 CAPABILITY > * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS > NAMESPACE LITERAL+ UIDPLUS CHILDREN > A0 OK CAPABILITY completed. > DEBUG: protocolConnect login, host=myFancyHost.org, user=myUsername, > password=<non-null> > A1 LOGIN myUsername myPassword > A1 OK LOGIN completed. > A2 CAPABILITY > * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS > NAMESPACE LITERAL+ UIDPLUS CHILDREN > A2 OK CAPABILITY completed. > DEBUG: setDebug: JavaMail version 1.4.1 > DEBUG: getProvider() returning > javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun > Microsystems, Inc] > DEBUG: mail.imap.fetchsize: 16384 > > Thanks for your help. > > Kind regards, > Wolfgang > > On Tue, 2009-01-27 at 10:16 -0800, Bill Shannon wrote: > > You can also simplify your expression by using a single OrTerm with > > three HeaderTerms, although it shouldn't make a difference. > > > > The debug output should help figure out what's going on. > > > > Paolo Spadafora wrote: > > > Hi, > > > You can enable debug in javamail and see what's the difference > between the 2 > > > imap search commands you run. > > > The SEARCH command is part of IMAPv4 spec, I don't think you need > any > > > special capabilities on your server. > > > > > > Bye, > > > Paolo > > > > > > > > > > > > -----Messaggio originale----- > > > Da: A mailing list for discussion of the JavaMail(tm) API > > > [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang > Beikircher > > > Inviato: martedì 27 gennaio 2009 15.58 > > > A: JAVAMAIL-INTEREST@... > > > Oggetto: JavaMail IMAPFolder search command > > > > > > Hi there! > > > > > > I'm quite new to the list and therefore I don't know if I'm in the > > > correct place. I hope so. :) > > > > > > Actually I'm trying to issue a SEARCH command (through f.search > where f > > > is an object of IMAPFolder) to an Exchange server. The task is to > search > > > out 3 mails (on the basis of the Message-Id in the header). > Therefore, > > > I'm constructing a SearchTerm-object. As far as I understood, I have > to > > > construct it like a tree. My tree is looking similar to this one: > > > > > > OrTerm > > > | | > > > HeaderTerm OrTerm > > > | | > > > HeaderTerm HeaderTerm > > > > > > If I'm issueing that command, the server returns 0 elements. If I > issue > > > the HeaderTerms seperately I get the desired elements. > > > > > > So, what I'm doing wrong? Must the mail server have some > capabilities to > > > perform searches with a higher depth than 1? > > > > > > Thanks for your help. > > > > > > Kind regards, > > > Wolfgang > > > > > > P.S: I'm working with JavaMail version 1.4.1. > > > > > > > =========================================================================== > > > To unsubscribe, send email to listserv@... and include in > the body > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > email to > > > listserv@... and include in the body of the message "help". > > > > > > > =========================================================================== > > > To unsubscribe, send email to listserv@... and include in > the body > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > email to > > > listserv@... and include in the body of the message "help". > > > > > =========================================================================== > > To unsubscribe, send email to listserv@... and include in the > body > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > email to > > listserv@... and include in the body of the message "help". Wolfgang Beikircher Center for Applied Software Engineering (CASE) Free University of Bozen/Bolzano Mustergasse/Via della Mostra 4 39100 Bozen/Bolzano Italy =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: R: R: R: JavaMail IMAPFolder search commandOn Thu, 2009-01-29 at 10:58 +0100, Paolo Spadafora wrote:
> Is the debug output of the search command you run on Zimbra the same? > I mean this: SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL > Imap Spec doesn't say much, just OR <expr1> <expr2> Yes, the debug output is completely the same. And there it works in all situations (no matter which flag is on which positions). > > Try writing a custom command like this(1): > SEARCH OR (ANSWERED) ( OR (UNSEEN) (UNDELETED) ) ALL > > Something like this (didn't test it!): > public class TestOrCommand implements IMAPFolder.ProtocolCommand { > public Object doCommand(IMAPProtocol protocol) throws ProtocolException{ > Argument args = new Argument(); > args.writeString("ALL"); > Response[] r = protocol.command("SEARCH OR (ANSWERED) ( OR (UNSEEN) (UNDELETED) ) ", args); > //check the output, has to be as (1) > Response response = r[r.length - 1]; > // Grab all SORT responses > if (response.isOK()) { // command successful > for (int i = 0, len = r.length; i < len; i++) { > if (!(r[i] instanceof IMAPResponse)) > continue; > IMAPResponse ir = (IMAPResponse) r[i]; > if (ir.keyEquals("SEARCH")) { > String num; > while ((num = ir.readAtomString()) != null) { > System.out.print(num+" "); > } > } > } > } > protocol.notifyResponseHandlers(r); > protocol.handleResult(response); > return null; //just a test, don't need a return value > } > > } > > TestOrCommand com = new TestOrCommand(); > folder.open(Folder.READ_ONLY); > folder.doCommand(com); I tried your suggestion. But it does not work. The following error will be thrown: A5 BAD Protocol Error: "Invalid key supplied in the SEARCH command". This is the stack trace: javax.mail.MessagingException: A5 BAD Protocol Error: "Invalid key supplied in the SEARCH command".; nested exception is: com.sun.mail.iap.BadCommandException: A5 BAD Protocol Error: "Invalid key supplied in the SEARCH command". at com.sun.mail.imap.IMAPFolder.doCommand(IMAPFolder.java:2588) at org.zimbra.exchange.MyTestClass.main(MyTestClass.java:305) Caused by: com.sun.mail.iap.BadCommandException: A5 BAD Protocol Error: "Invalid key supplied in the SEARCH command". at com.sun.mail.iap.Protocol.handleResult(Protocol.java:343) at org.zimbra.exchange.TestOrCommand.doCommand(TestOrCommand.java:32) at com.sun.mail.imap.IMAPFolder.doProtocolCommand(IMAPFolder.java:2629) at com.sun.mail.imap.IMAPFolder.doCommand(IMAPFolder.java:2583) ... 1 more I tried also to construct different search strings but all of them do not work. I tried following variations: - SEARCH OR (ANSWERED) ( OR (UNSEEN) (UNDELETED) ) - SEARCH OR (ANSWERED) OR (UNSEEN) (UNDELETED) - SEARCH OR ((ANSWERED) (UNSEEN) (UNDELETED)) - SEARCH OR (ANSWERED UNSEEN UNDELETED) In the rfc there is one line which might explain the whole behaviour: "[...] When multiple keys are specified, the result is the intersection (AND function) of all the messages that match those keys. [...]" > > And see how it goes. > > > Paolo > > > -----Messaggio originale----- > Da: A mailing list for discussion of the JavaMail(tm) API [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher > Inviato: giovedì 29 gennaio 2009 9.25 > A: JAVAMAIL-INTEREST@... > Oggetto: Re: R: R: JavaMail IMAPFolder search command > > Okay, I tried it now with the 'FlagTerm'. I search of emails with the > following flags: UNSEEN, ANSWERED, UNDELETED. All of these flags are > connected through OR. I expect as a result all mails of the folder > because no one is marked as deleted. > > Situation in my folder: 11 mails are marked as ANSWERED, 0 mails are > marked as DELETED, and 90 mails are marked as SEEN. > > If I executed the search command only with the UNDELETED flag, I got the > correct result (reference to all mails). The search command in > connection with both other terms, I got the empty set. > > Just for curiosity, I tried to mark some mails (3 mails) as UNSEEN. > Therefore, each search command issued alone would return some result > set. To my surprise I got exactly these mails which I marked as UNSEEN. > It seems to me, that Exchange looks only to the last 2 terms in the > search command. > > Therefore I tried to switch the single search terms and... boom... I got > another result. > > My conclusion is, that Exchange searches only for the last 2 terms in > the OR conjunction. Do you agree on that? Or is it on the side of > JavaMail (maybe the command must be put somehow in brackets)? > > Here is the list of commands issued to the server: > 1. case: 11 mails ANSWERED, 0 mails DELETED, 0 mails UNSEEN > > A6 SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL > * SEARCH > A6 OK SEARCH completed. > > 2. case: 11 mails ANSWERED, 0 mails DELETED, 3 mails UNSEEN > > A6 SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL > * SEARCH 87 88 89 > A6 OK SEARCH completed. > > 3. case: 11 mails ANSWERED, 0 mails DELETED, 3 mails UNSEEN (switch > ordering of search terms) > > A6 SEARCH OR OR (UNSEEN) (ANSWERED) (UNDELETED) ALL > * SEARCH 22 24 26 36 38 50 61 62 65 68 74 > A6 OK SEARCH completed. > > On Wed, 2009-01-28 at 18:02 +0100, Paolo Spadafora wrote: > > Check to see if it happens only for headerterm or any other term search. > > Try with the same code but use flagterm or another term class and use simple values, avoid special chars, let's see what happens. > > > > Bye. > > > > Paolo > > > > > > -----Messaggio originale----- > > Da: A mailing list for discussion of the JavaMail(tm) API [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher > > Inviato: mercoledì 28 gennaio 2009 14.51 > > A: JAVAMAIL-INTEREST@... > > Oggetto: Re: R: JavaMail IMAPFolder search command > > > > Yes, I know. I tried also that variant but with no success. > > > > This is the debug output I get from javaMail when issueing the command: > > A6 SEARCH OR OR HEADER Message-ID > > mailman.0.1233063092.30210.devel@... HEADER Message-ID > > rt-3.4.5-16942-1232966693-1122.46544-5-0@... HEADER Message-ID > > 1233063449.7818.12.camel@... ALL > > * SEARCH > > A6 OK SEARCH completed. > > > > This is the debug output when I try to search with 2 terms connected > > through a OrTerm: > > A6 SEARCH OR HEADER Message-ID > > mailman.0.1233063092.30210.devel@... HEADER Message-ID > > rt-3.4.5-16942-1232966693-1122.46544-5-0@... ALL > > * SEARCH 66 72 > > A6 OK SEARCH completed. > > > > You can clearly see, that in the second example there will be returned 2 > > mail items (66, 72). > > > > This is my code which returns such results. Maybe I didn't understand > > how to use the SearchTerm-constructs: > > [...] > > > > IMAPFolder f = (IMAPFolder) > > eStore.getDefaultFolder().getFolder("inbox"); > > > > > > f.open(Folder.READ_ONLY); > > > > SearchTerm a = new HeaderTerm(Def.HEADER_MESSAGE_ID, > > "mailman.0.1233063092.30210.devel@..."); > > SearchTerm b = new HeaderTerm(Def.HEADER_MESSAGE_ID, > > "rt-3.4.5-16942-1232966693-1122.46544-5-0@..."); > > SearchTerm c = new OrTerm(a, b); > > SearchTerm d = new HeaderTerm(Def.HEADER_MESSAGE_ID, > > "1233063449.7818.12.camel@..."); > > SearchTerm g = new OrTerm(new SearchTerm[] {a, b, d}); > > > > Message[] ms = f.search(c); > > > > [...] > > > > As a side note: I'm using an Exchange 2003 server for my tests. I tried > > also to use another server (Zimbra server) and there it is working. So, > > only the Exchange server returns such strange results. The login > > procedure produces the following debug output. Maybe does it make sense > > for you... > > > > * OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 > > (myServer.org) ready. > > A0 CAPABILITY > > * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS > > NAMESPACE LITERAL+ UIDPLUS CHILDREN > > A0 OK CAPABILITY completed. > > DEBUG: protocolConnect login, host=myFancyHost.org, user=myUsername, > > password=<non-null> > > A1 LOGIN myUsername myPassword > > A1 OK LOGIN completed. > > A2 CAPABILITY > > * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS > > NAMESPACE LITERAL+ UIDPLUS CHILDREN > > A2 OK CAPABILITY completed. > > DEBUG: setDebug: JavaMail version 1.4.1 > > DEBUG: getProvider() returning > > javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun > > Microsystems, Inc] > > DEBUG: mail.imap.fetchsize: 16384 > > > > Thanks for your help. > > > > Kind regards, > > Wolfgang > > > > On Tue, 2009-01-27 at 10:16 -0800, Bill Shannon wrote: > > > You can also simplify your expression by using a single OrTerm with > > > three HeaderTerms, although it shouldn't make a difference. > > > > > > The debug output should help figure out what's going on. > > > > > > Paolo Spadafora wrote: > > > > Hi, > > > > You can enable debug in javamail and see what's the difference > > between the 2 > > > > imap search commands you run. > > > > The SEARCH command is part of IMAPv4 spec, I don't think you need > > any > > > > special capabilities on your server. > > > > > > > > Bye, > > > > Paolo > > > > > > > > > > > > > > > > -----Messaggio originale----- > > > > Da: A mailing list for discussion of the JavaMail(tm) API > > > > [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang > > Beikircher > > > > Inviato: martedì 27 gennaio 2009 15.58 > > > > A: JAVAMAIL-INTEREST@... > > > > Oggetto: JavaMail IMAPFolder search command > > > > > > > > Hi there! > > > > > > > > I'm quite new to the list and therefore I don't know if I'm in the > > > > correct place. I hope so. :) > > > > > > > > Actually I'm trying to issue a SEARCH command (through f.search > > where f > > > > is an object of IMAPFolder) to an Exchange server. The task is to > > search > > > > out 3 mails (on the basis of the Message-Id in the header). > > Therefore, > > > > I'm constructing a SearchTerm-object. As far as I understood, I have > > to > > > > construct it like a tree. My tree is looking similar to this one: > > > > > > > > OrTerm > > > > | | > > > > HeaderTerm OrTerm > > > > | | > > > > HeaderTerm HeaderTerm > > > > > > > > If I'm issueing that command, the server returns 0 elements. If I > > issue > > > > the HeaderTerms seperately I get the desired elements. > > > > > > > > So, what I'm doing wrong? Must the mail server have some > > capabilities to > > > > perform searches with a higher depth than 1? > > > > > > > > Thanks for your help. > > > > > > > > Kind regards, > > > > Wolfgang > > > > > > > > P.S: I'm working with JavaMail version 1.4.1. > > > > > > > > > > =========================================================================== > > > > To unsubscribe, send email to listserv@... and include in > > the body > > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > > email to > > > > listserv@... and include in the body of the message "help". > > > > > > > > > > =========================================================================== > > > > To unsubscribe, send email to listserv@... and include in > > the body > > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > > email to > > > > listserv@... and include in the body of the message "help". > > > > > > > > =========================================================================== > > > To unsubscribe, send email to listserv@... and include in the > > body > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > > email to > > > listserv@... and include in the body of the message "help". Wolfgang Beikircher Center for Applied Software Engineering (CASE) Free University of Bozen/Bolzano Mustergasse/Via della Mostra 4 39100 Bozen/Bolzano Italy =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
R: R: R: R: JavaMail IMAPFolder search commandI think it's a little bug in Exchange server.
Paolo -----Messaggio originale----- Da: Wolfgang Beikircher [mailto:wolfgang.beikircher@...] Inviato: giovedì 29 gennaio 2009 14.29 A: Paolo Spadafora; JAVAMAIL-INTEREST@... Oggetto: Re: R: R: R: JavaMail IMAPFolder search command On Thu, 2009-01-29 at 10:58 +0100, Paolo Spadafora wrote: > Is the debug output of the search command you run on Zimbra the same? > I mean this: SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL > Imap Spec doesn't say much, just OR <expr1> <expr2> Yes, the debug output is completely the same. And there it works in all situations (no matter which flag is on which positions). > > Try writing a custom command like this(1): > SEARCH OR (ANSWERED) ( OR (UNSEEN) (UNDELETED) ) ALL > > Something like this (didn't test it!): > public class TestOrCommand implements IMAPFolder.ProtocolCommand { > public Object doCommand(IMAPProtocol protocol) throws ProtocolException{ > Argument args = new Argument(); > args.writeString("ALL"); > Response[] r = protocol.command("SEARCH OR (ANSWERED) ( OR (UNSEEN) (UNDELETED) ) ", args); > //check the output, has to be as (1) > Response response = r[r.length - 1]; > // Grab all SORT responses > if (response.isOK()) { // command successful > for (int i = 0, len = r.length; i < len; i++) { > if (!(r[i] instanceof IMAPResponse)) > continue; > IMAPResponse ir = (IMAPResponse) r[i]; > if (ir.keyEquals("SEARCH")) { > String num; > while ((num = ir.readAtomString()) != null) { > System.out.print(num+" "); > } > } > } > } > protocol.notifyResponseHandlers(r); > protocol.handleResult(response); > return null; //just a test, don't need a return value > } > > } > > TestOrCommand com = new TestOrCommand(); > folder.open(Folder.READ_ONLY); > folder.doCommand(com); I tried your suggestion. But it does not work. The following error will be thrown: A5 BAD Protocol Error: "Invalid key supplied in the SEARCH command". This is the stack trace: javax.mail.MessagingException: A5 BAD Protocol Error: "Invalid key supplied in the SEARCH command".; nested exception is: com.sun.mail.iap.BadCommandException: A5 BAD Protocol Error: "Invalid key supplied in the SEARCH command". at com.sun.mail.imap.IMAPFolder.doCommand(IMAPFolder.java:2588) at org.zimbra.exchange.MyTestClass.main(MyTestClass.java:305) Caused by: com.sun.mail.iap.BadCommandException: A5 BAD Protocol Error: "Invalid key supplied in the SEARCH command". at com.sun.mail.iap.Protocol.handleResult(Protocol.java:343) at org.zimbra.exchange.TestOrCommand.doCommand(TestOrCommand.java:32) at com.sun.mail.imap.IMAPFolder.doProtocolCommand(IMAPFolder.java:2629) at com.sun.mail.imap.IMAPFolder.doCommand(IMAPFolder.java:2583) ... 1 more I tried also to construct different search strings but all of them do not work. I tried following variations: - SEARCH OR (ANSWERED) ( OR (UNSEEN) (UNDELETED) ) - SEARCH OR (ANSWERED) OR (UNSEEN) (UNDELETED) - SEARCH OR ((ANSWERED) (UNSEEN) (UNDELETED)) - SEARCH OR (ANSWERED UNSEEN UNDELETED) In the rfc there is one line which might explain the whole behaviour: "[...] When multiple keys are specified, the result is the intersection (AND function) of all the messages that match those keys. [...]" > > And see how it goes. > > > Paolo > > > -----Messaggio originale----- > Da: A mailing list for discussion of the JavaMail(tm) API [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher > Inviato: giovedì 29 gennaio 2009 9.25 > A: JAVAMAIL-INTEREST@... > Oggetto: Re: R: R: JavaMail IMAPFolder search command > > Okay, I tried it now with the 'FlagTerm'. I search of emails with the > following flags: UNSEEN, ANSWERED, UNDELETED. All of these flags are > connected through OR. I expect as a result all mails of the folder > because no one is marked as deleted. > > Situation in my folder: 11 mails are marked as ANSWERED, 0 mails are > marked as DELETED, and 90 mails are marked as SEEN. > > If I executed the search command only with the UNDELETED flag, I got the > correct result (reference to all mails). The search command in > connection with both other terms, I got the empty set. > > Just for curiosity, I tried to mark some mails (3 mails) as UNSEEN. > Therefore, each search command issued alone would return some result > set. To my surprise I got exactly these mails which I marked as UNSEEN. > It seems to me, that Exchange looks only to the last 2 terms in the > search command. > > Therefore I tried to switch the single search terms and... boom... I got > another result. > > My conclusion is, that Exchange searches only for the last 2 terms in > the OR conjunction. Do you agree on that? Or is it on the side of > JavaMail (maybe the command must be put somehow in brackets)? > > Here is the list of commands issued to the server: > 1. case: 11 mails ANSWERED, 0 mails DELETED, 0 mails UNSEEN > > A6 SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL > * SEARCH > A6 OK SEARCH completed. > > 2. case: 11 mails ANSWERED, 0 mails DELETED, 3 mails UNSEEN > > A6 SEARCH OR OR (ANSWERED) (UNSEEN) (UNDELETED) ALL > * SEARCH 87 88 89 > A6 OK SEARCH completed. > > 3. case: 11 mails ANSWERED, 0 mails DELETED, 3 mails UNSEEN (switch > ordering of search terms) > > A6 SEARCH OR OR (UNSEEN) (ANSWERED) (UNDELETED) ALL > * SEARCH 22 24 26 36 38 50 61 62 65 68 74 > A6 OK SEARCH completed. > > On Wed, 2009-01-28 at 18:02 +0100, Paolo Spadafora wrote: > > Check to see if it happens only for headerterm or any other term search. > > Try with the same code but use flagterm or another term class and use simple values, avoid special chars, let's see what happens. > > > > Bye. > > > > Paolo > > > > > > -----Messaggio originale----- > > Da: A mailing list for discussion of the JavaMail(tm) API [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang Beikircher > > Inviato: mercoledì 28 gennaio 2009 14.51 > > A: JAVAMAIL-INTEREST@... > > Oggetto: Re: R: JavaMail IMAPFolder search command > > > > Yes, I know. I tried also that variant but with no success. > > > > This is the debug output I get from javaMail when issueing the command: > > A6 SEARCH OR OR HEADER Message-ID > > mailman.0.1233063092.30210.devel@... HEADER Message-ID > > rt-3.4.5-16942-1232966693-1122.46544-5-0@... HEADER Message-ID > > 1233063449.7818.12.camel@... ALL > > * SEARCH > > A6 OK SEARCH completed. > > > > This is the debug output when I try to search with 2 terms connected > > through a OrTerm: > > A6 SEARCH OR HEADER Message-ID > > mailman.0.1233063092.30210.devel@... HEADER Message-ID > > rt-3.4.5-16942-1232966693-1122.46544-5-0@... ALL > > * SEARCH 66 72 > > A6 OK SEARCH completed. > > > > You can clearly see, that in the second example there will be returned 2 > > mail items (66, 72). > > > > This is my code which returns such results. Maybe I didn't understand > > how to use the SearchTerm-constructs: > > [...] > > > > IMAPFolder f = (IMAPFolder) > > eStore.getDefaultFolder().getFolder("inbox"); > > > > > > f.open(Folder.READ_ONLY); > > > > SearchTerm a = new HeaderTerm(Def.HEADER_MESSAGE_ID, > > "mailman.0.1233063092.30210.devel@..."); > > SearchTerm b = new HeaderTerm(Def.HEADER_MESSAGE_ID, > > "rt-3.4.5-16942-1232966693-1122.46544-5-0@..."); > > SearchTerm c = new OrTerm(a, b); > > SearchTerm d = new HeaderTerm(Def.HEADER_MESSAGE_ID, > > "1233063449.7818.12.camel@..."); > > SearchTerm g = new OrTerm(new SearchTerm[] {a, b, d}); > > > > Message[] ms = f.search(c); > > > > [...] > > > > As a side note: I'm using an Exchange 2003 server for my tests. I tried > > also to use another server (Zimbra server) and there it is working. So, > > only the Exchange server returns such strange results. The login > > procedure produces the following debug output. Maybe does it make sense > > for you... > > > > * OK Microsoft Exchange Server 2003 IMAP4rev1 server version 6.5.7638.1 > > (myServer.org) ready. > > A0 CAPABILITY > > * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS > > NAMESPACE LITERAL+ UIDPLUS CHILDREN > > A0 OK CAPABILITY completed. > > DEBUG: protocolConnect login, host=myFancyHost.org, user=myUsername, > > password=<non-null> > > A1 LOGIN myUsername myPassword > > A1 OK LOGIN completed. > > A2 CAPABILITY > > * CAPABILITY IMAP4 IMAP4rev1 IDLE LOGIN-REFERRALS MAILBOX-REFERRALS > > NAMESPACE LITERAL+ UIDPLUS CHILDREN > > A2 OK CAPABILITY completed. > > DEBUG: setDebug: JavaMail version 1.4.1 > > DEBUG: getProvider() returning > > javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun > > Microsystems, Inc] > > DEBUG: mail.imap.fetchsize: 16384 > > > > Thanks for your help. > > > > Kind regards, > > Wolfgang > > > > On Tue, 2009-01-27 at 10:16 -0800, Bill Shannon wrote: > > > You can also simplify your expression by using a single OrTerm with > > > three HeaderTerms, although it shouldn't make a difference. > > > > > > The debug output should help figure out what's going on. > > > > > > Paolo Spadafora wrote: > > > > Hi, > > > > You can enable debug in javamail and see what's the difference > > between the 2 > > > > imap search commands you run. > > > > The SEARCH command is part of IMAPv4 spec, I don't think you need > > any > > > > special capabilities on your server. > > > > > > > > Bye, > > > > Paolo > > > > > > > > > > > > > > > > -----Messaggio originale----- > > > > Da: A mailing list for discussion of the JavaMail(tm) API > > > > [mailto:JAVAMAIL-INTEREST@...] Per conto di Wolfgang > > Beikircher > > > > Inviato: martedì 27 gennaio 2009 15.58 > > > > A: JAVAMAIL-INTEREST@... > > > > Oggetto: JavaMail IMAPFolder search command > > > > > > > > Hi there! > > > > > > > > I'm quite new to the list and therefore I don't know if I'm in the > > > > correct place. I hope so. :) > > > > > > > > Actually I'm trying to issue a SEARCH command (through f.search > > where f > > > > is an object of IMAPFolder) to an Exchange server. The task is to > > search > > > > out 3 mails (on the basis of the Message-Id in the header). > > Therefore, > > > > I'm constructing a SearchTerm-object. As far as I understood, I have > > to > > > > construct it like a tree. My tree is looking similar to this one: > > > > > > > > OrTerm > > > > | | > > > > HeaderTerm OrTerm > > > > | | > > > > HeaderTerm HeaderTerm > > > > > > > > If I'm issueing that command, the server returns 0 elements. If I > > issue > > > > the HeaderTerms seperately I get the desired elements. > > > > > > > > So, what I'm doing wrong? Must the mail server have some > > capabilities to > > > > perform searches with a higher depth than 1? > > > > > > > > Thanks for your help. > > > > > > > > Kind regards, > > > > Wolfgang > > > > > > > > P.S: I'm working with JavaMail version 1.4.1. > > > > > > > > > > =========================================================================== > > > > To unsubscribe, send email to listserv@... and include in > > the body > > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > > email to > > > > listserv@... and include in the body of the message "help". > > > > > > > > > > =========================================================================== > > > > To unsubscribe, send email to listserv@... and include in > > the body > > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > > email to > > > > listserv@... and include in the body of the message "help". > > > > > > > > =========================================================================== > > > To unsubscribe, send email to listserv@... and include in the > > body > > > of the message "signoff JAVAMAIL-INTEREST". For general help, send > > email to > > > listserv@... and include in the body of the message "help". Wolfgang Beikircher Center for Applied Software Engineering (CASE) Free University of Bozen/Bolzano Mustergasse/Via della Mostra 4 39100 Bozen/Bolzano Italy =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: R: R: R: JavaMail IMAPFolder search commandWolfgang Beikircher wrote:
> In the rfc there is one line which might explain the whole behaviour: > "[...] > When multiple keys are specified, the result is the intersection (AND > function) of all the messages that match those keys. > [...]" Unless you use the OR key. Read the entire SEARCH spec. All evidence suggests it's a bug in Exchange. You know where to find Microsoft. If you get an answer from them, let us know. =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
| Free embeddable forum powered by Nabble | Forum Help |