+1 vote

Please help. I have your library Limilabs.Mail in my program.

I am not able to solve problem with searching in inbox

I need search in inbox with following combination of conditions
Address TO is "example1@domain.com" and flag is UNSEEN.

I tried to use

imap.Search("TO example1@domain.com \UNSEEN"); 

I get error

System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Limilabs.Client.IMAP.ICriterion'

Question is how should I create IMAP search with multiple criteria and not only flags?

I have this level of license - "Mail.dll single developer"

by

1 Answer

0 votes
 
Best answer

Expression search syntax should help. It allows creating complex IMAP search queries in code:

List<long> uids = imap.Search(
    Expression.And(
        Expression.To("example1@domain.com"),
        Expression.HasFlag(Flag.Unseen)));

You can find more details on how to search IMAP here:
https://www.limilabs.com/blog/how-to-search-imap-in-net

by (301k points)
...