andyedinborough / aenetmail

C# POP/IMAP Mail Client
370 stars 153 forks source link

Can't seem to filter using SearchCondition for a specific combo #153

Open Shogan opened 10 years ago

Shogan commented 10 years ago

Try as I may, I can't seem to filter out this criteria:

Messages should be:

I've tried various combos, this is my latest attempt, which didn't work either:

var catchAll = ic.SearchMessages(SearchCondition.Unseen() .Not(SearchCondition.Subject("offer") .Not(SearchCondition.Subject("offered") .Not(SearchCondition.Subject("wanted") .Not(SearchCondition.Subject("taken"))))).And(SearchCondition.To(mainAddress)));

My other filters which are also fairly complex (but don't use "Not") all work perfectly though. Am I doing my SearchCondition above wrong?

Shogan commented 10 years ago

Feel free to close this, I couldn't get a long list of nested conditions working nicely, so I ended up just creating my own matching methods with regex after doing an initial filter for SearchCondition.Unseen and SearchCondition.To. I then simply iterate the results of the above two search conditions and do my own nested checking on the subject / bodies of remaining messages in the result array.