【发布时间】:2013-05-09 10:40:29
【问题描述】:
我需要将邮件附件存储到本地硬盘驱动器中。是否有任何解决方法可以实现此目的?我正在使用 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的链接。
【问题讨论】: