+1 vote

Can you search by message id?

I see you have a header option to search by but not sure how to use it.

by (8.8k points)

1 Answer

0 votes
 
Best answer

Yes, with Mail.dll IMAP client you can search by any header using Imap.Search method and Expression class:

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

You can also use dedicated MessageID method:

List<long> uids =  imap.Search(Expression.MessageId("id@example.com"));

Message-ID header is available through IMail.MessageID property:

IMail email = new MailBuilder().CreateFromEml(eml)
string messageId = email.MessageID;
by (297k points)
...