0 votes

So, I know that I can search for specific email by the specific value of its "Message-Id" header:

List<long> uids =  imap.Search(
     Expression.Header("Message-ID", "<message@id.com>"));

But how to search for all emails that have Message-Id set and I don't know all the values for these Message-Ids?

by
retagged by

1 Answer

0 votes

First of all you can use Expression.MessageId instead of Expression.Header

List<long> uids = imap.Search(Expression.MessageId(email.MessageID));

How to search for all emails that have Message-Id set

All emails should have Message-Id header or the other way around: if an email doesn't have this header, it means it isn't a valid email message.

To search for all email that have particular header you should use this code:

List<long> uids = client.Search(Expression.HasHeader("any-header"));
by (301k points)
...