Aparna V
Aparna V

Reputation: 179

Finding out unread mails which do not have certain keywords included in the subject in my mailbox using Mail gem

I am able to read the unread emails with the word "development" from my mailbox using:

Mail.find(keys: ['UNSEEN','SUBJECT',"development"],:count => 100,:what =>:all).

I now want to retrieve the unread mails from my mailbox with out the word "development" in subject line.

I read RFC2060, section 6.4.4, and tried UNKEYWORD AND NOT methods, but it didn't help. Can anybody suggest me an appropriate answer for the same?

Upvotes: 0

Views: 297

Answers (1)

Eric Duminil
Eric Duminil

Reputation: 54223

Note that it is an IMAP query, so it uses Polish notation :

Mail.find(keys: ['UNSEEN', 'NOT', 'SUBJECT',"development"],:count => 100,:what =>:all)

It worked on my computer with Gmail IMAP.

One problem was that an Unseen mail was considered Seen as soon as I retrieved it to check subject and from.

Upvotes: 1

Related Questions