【发布时间】:2012-06-06 20:29:21
【问题描述】:
我正在使用 C# 和 AE.Net.Mail 库从 Gmail 中提取文件。我在处理大型 zip 文件时遇到问题。
这里用 Java 描述并解决了同样的问题:JavaMail BaseEncode64 Error
有人知道如何使用 C# 和 AE.Net.Mail 库设置部分提取标志吗?
【问题讨论】:
标签: c# imap gmail-imap
我正在使用 C# 和 AE.Net.Mail 库从 Gmail 中提取文件。我在处理大型 zip 文件时遇到问题。
这里用 Java 描述并解决了同样的问题:JavaMail BaseEncode64 Error
有人知道如何使用 C# 和 AE.Net.Mail 库设置部分提取标志吗?
【问题讨论】:
标签: c# imap gmail-imap
使用(或查看)S22.Imap。这是一个 AE.Net.Mail 文档,带有一些附加功能。
来自示例:仅下载小于 2 兆字节的附件
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;
}
);
}
}
}
}
【讨论】:
SentSince 搜索过滤器,但它无法正常工作 - 返回我拥有的所有电子邮件。不一定是图书馆的错