【问题标题】:Load attachments files names without attachments in c#在c#中加载不带附件的附件文件名
【发布时间】:2011-08-24 11:49:25
【问题描述】:

首先,对不起我的英语。

我想在邮箱中显示附件名称文件列表。然后从这个列表中,用户可以选择他们想在硬盘上下载哪些附件——例如在这个程序中: http://www.mailresender.com.ar/Read.html

我已经在 Koolwired.Imap 中写过这个:

for (int i = 0; i < mbStructure.BodyParts.Count; i++) // i = number of parts of body
{
     if (mbStructure.BodyParts[i].Attachment)
     {
         mbStructure = command.FetchBodyPart(mbStructure, i);
         System.Console.WriteLine(mbStructure.BodyParts[i].Disposition); // Disposition contains file name
         //System.Console.WriteLine(mbStructure.BodyParts[i].Data); //  Data contains entire file
      }
}

但问题是不仅文件名被加载到内存中,而且数据二进制文件(整个附件文件由 FetchBodyPart 方法加载) - 所以如果附件中的文件大小很长(例如 20 MB)所有这 20 MB 也必须加载到内存中,因此显示文件名列表将持续很长时间。

有没有办法只加载附件文件名而不加载文件? c# 中的哪个库可以支持这一点?

【问题讨论】:

    标签: c# imap attachment


    【解决方案1】:

    您的问题的答案是 ImapCommand.FetchBodyStructure,但是当我浏览源代码时,我敢打赌它会在某些电子邮件上失败。

    你也可以看看Mail.dll IMAP component,尤其是这篇博文可能会有用:

    http://www.lesnikowski.com/blog/index.php/get-email-information-from-imap-fast/

    请注意,Mail.dll 是我创建的商业产品。

    【讨论】:

      猜你喜欢
      • 2018-11-18
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 1970-01-01
      • 2019-10-05
      • 2013-11-19
      • 2019-02-27
      • 2012-09-03
      相关资源
      最近更新 更多