简体   繁体   English

通过MimeKit搜索本地Eml文件

[英]Searching Local Eml Files via MimeKit

I am trying to read, show and search EML files with attachments downloaded on my computer. 我正在尝试阅读,显示和搜索带有下载到我计算机上的附件的EML文件。 To do that; 要做到这一点; I am using MimeKit v2.1.0. 我正在使用MimeKit v2.1.0。 It's okay when I read and show the files with using MimeMessage. 当我使用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. 据我了解,MimeKit没有搜索选项。 What can be able to do that is MailKit but this time, I could not read local EML files. 可以执行此操作的是MailKit,但这一次,我无法读取本地EML文件。 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. 因此,总而言之,我正在寻找一种使用MimeKit进行搜索或使用MailKit读取本地EML文件的方法。 Any help appreciated. 任何帮助表示赞赏。

MailKit's search APIs are for IMAP. MailKit的搜索API用于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. 当然,有人可以为本地消息实现IMailFolder接口(采用mbox还是Maildir格式?),但是任何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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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