我正在使用一个控制台应用程序通过IMAP服务从邮件中下载文件。在应用程序中,我使用“S22.Imap”程序集进行IMAP操作,我已经获取到了包含附件的所有邮件的IEnumerable可枚举集合。请问如何下载这些文件?
using (ImapClient client = new ImapClient(hostname, 993, username, password, AuthMethod.Login, true))
{
IEnumerable<uint> uids = client.Search(SearchCondition.Subject("Attachments"));
IEnumerable<MailMessage> messages = client.GetMessages(uids,
(Bodypart part) =>
{
if (part.Disposition.Type == ContentDispositionType.Attachment)
{
if (part.Type == ContentType.Application &&
part.Subtype == "VND.MS-EXCEL")
{
return true;
}
else
{
return false;
}
}
return true;
}
);
}
如果您能提供解决方案,我将不胜感激。