6

I need to find all mails in IMAP mailbox which contains somestring in BODY and is FROM someone@me.com or TO someone@me.com.

Trying to do:

49:51.53 > JBPM3 SEARCH CHARSET utf-8 "BODY \"somestring\" (OR (TO \"someone@me.com\") (FROM \"someone@me.com\"))"

Receiving:

49:51.71 < JBPM3 BAD Could not parse command

How to make it work using GMail?

Oleksandr
  • 101
  • 1
  • 2
  • 4

1 Answers1

6

You may skip parenthesis '(' ')' to group logical expressions in IMAP. Parenthesis are not needed in Polish Notation (see edit below):

A0001 SEARCH CHARSET utf-8 BODY "somestring" OR TO "someone@me.com" FROM "someone@me.com"

You could also use gmail search syntax (X-GM-RAW) command: http://www.limilabs.com/blog/search-gmail-using-gmails-search-syntax

[Edit] Parenthesis are sometimes required in IMAP SEARCH. This is because AND operator can have more than 2 operands and is not explicitly defined: http://www.limilabs.com/blog/imap-search-requires-parentheses

Pawel Lesnikowski
  • 6,264
  • 4
  • 38
  • 42
  • 3
    Just a quick correction - IMAP does not use reverse polish notation (which would be more like: `"somestring" BODY "someone@me.com" TO "someone@me.com" FROM OR AND`) but simply polish (or prefix) notation. IMAP's design is based on LISP, from what I can gather. – Jules May 25 '13 at 10:51