[英]AE.Net.Mail Imap partial fetch
我正在使用C#和AE.Net.Mail庫從Gmail中提取文件。 我在處理大型zip文件時遇到問題。
使用Java在此處描述和解決了相同的問題: JavaMail BaseEncode64錯誤
有誰知道如何使用C#和AE.Net.Mail庫設置部分提取標志?
跟着(或看看) S22.Imap 。 這是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;
}
);
}
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.