我需要将消息附件存储到本地硬盘驱动器中。是否有任何解决方法可以实现这一点?我正在使用 S22.Imap dll
using (ImapClient Client = new ImapClient("imap.gmail.com", 993,
"xxxxxx@xxxxx.com", "xxxxxxxxxx", S22.Imap.AuthMethod.Login, true))
{
uint[] uids = Client.Search(
SearchCondition.From("test.account.rac@gmail.com").And(
SearchCondition.SentSince(new DateTime(2013, 5, 8))).And(
SearchCondition.SentBefore(new DateTime(2013, 5, 9)))
);
MailMessage[] messages = Client.GetMessages(uids,
(Bodypart part) =>
{
// We're only interested in attachments
if (part.Disposition.Type == ContentDispositionType.Attachment)
{
Int64 TwoMegabytes = (1024 * 1024 * 2);
if (part.Size > TwoMegabytes)
{
// Don't download this attachment
return false;
}
}
// fetch MIME part and include it in the returned MailMessage instance
return true;
}
);
string attachment_name;
if (messages[0].Attachments.Count > 0)
{
}
}
没有将这些附件保存到本地驱动器的内置方法。此外,这可以通过 S22.Mail.dll 库实现,但我找不到这个库。有人可以为我提供解决方案吗?这是 S22.Mail 源代码的链接https://github.com/smiley22/S22.Mail。