我使用控制台应用程序使用IMAP服务从邮件中下载文档。我在IMAP的应用程序中使用“S22.Imap”程序集。我收到了包含IEnumerable中附加文件的所有邮件。我怎样才能下载这些文件?如何使用IMAP从C#下载gmail的附件?
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;
}
);
}
我将不胜感激,如果你给一个解决方案
的截图,扩大基地,而你应该得到[ContentStream(https://msdn.microsoft.com/en-us/library/System.Net.Mail。附件%28v = vs.110%29.aspx) – Martheen