AE.Net.Mail Imap 部分提取
本文关键字:提取 Imap Net Mail AE | 更新日期: 2023-09-27 18:36:22
我正在使用C#和AE。Net.Mail库,用于从Gmail中提取文件。我在使用大型 zip 文件时遇到问题。
这里用Java描述并解决了同样的问题:JavaMail BaseEncode64错误
有谁知道如何使用 C# 和 AE 设置部分提取标志。网络邮件库?
使用(或看看)S22。艾玛普。这是一个AE。Net.Mail记录了一些额外的内容。
来自示例:仅当附件小于 2 MB 时才下载附件
using System;
using S22.Imap;
namespace Test {
class Program {
static void Main(string[] args)
{
using (ImapClient Client = new ImapClient("imap.gmail.com", 993,
"username", "password", Authmethod.Login, true))
{
// This returns all messages sent since August 23rd 2012
uint[] uids = Client.Search(
SearchCondition.SentSince( new DateTime(2012, 8, 23) )
);
// Our lambda expression will be evaluated for every MIME part
// of every mail message in the uids array
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;
}
);
}
}
}
}