简体   繁体   中英

Searching Local Eml Files via MimeKit

I am trying to read, show and search EML files with attachments downloaded on my computer. To do that; I am using MimeKit v2.1.0. It's okay when I read and show the files with using MimeMessage. However, I have many messages and need to be able to search with a few words. As i understand, MimeKit has no search option. What can be able to do that is MailKit but this time, I could not read local EML files. I have searched for couple days to find a solution but returned with empty hands.

So, to sum up, I am looking for a way either search with MimeKit or read local EML files with MailKit. Any help appreciated.

MailKit's search APIs are for IMAP. Granted, someone could implement the IMailFolder interface for local messages (in mbox or Maildir format?), but that has not been done by anyone afaik.

That said, you can do this:

static bool Search (string fileName, string text)
{
    var message = MimeMessage.Load (fileName);
    var body = message.TextBody;

    return body != null && body.Contains (text);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM