mscdex / node-imap

An IMAP client module for node.js.
MIT License
2.17k stars 380 forks source link

IMAP Search Negation not working #698

Open anshulCoder opened 6 years ago

anshulCoder commented 6 years ago

Hi, I was trying a simple search in mails inbox folder here is my code so far:

imap.search([ ['FROM', 'Pinterest'], 'OR', ['!SUBJECT', 'Sorry. We had to delete one of your Pins on Pinterest.'] ], (err, ids) => {

Here even after putting a ! sign to negate the condition it was giving a same result like true condition, is the above code correct?

mscdex commented 6 years ago

No, the criteria/operand goes first, so it would be something like:

[
  [ 'OR',
    ['FROM', 'Pinterest'],
    ['!SUBJECT', 'Sorry. We had to delete one of your Pins on Pinterest.']
  ]
]

assuming you want either of those two to be true.

anshulCoder commented 6 years ago

Criteria 'OR' is optional for me the main issue is with the negation sign '!' negation is not only working, giving same result with or without it