C# AE.Net.Mail Imap部分获取

C# AE.Net.Mail Imap部分获取,c#,imap,gmail-imap,C#,Imap,Gmail Imap,我正在使用C#和库从Gmail中提取文件。我在处理大型zip文件时遇到问题 同样的问题在这里用Java描述和解决: 有人知道如何使用C#和AE.Net.Mail库设置部分获取标志吗?使用(或查看)。这是一封AE.Net.Mail,记录了一些额外信息 示例:仅当附件小于2 MB时才下载附件 using System; using S22.Imap; namespace Test { class Program { static void Main(string[] args) {

我正在使用C#和库从Gmail中提取文件。我在处理大型zip文件时遇到问题

同样的问题在这里用Java描述和解决:

有人知道如何使用C#和AE.Net.Mail库设置部分获取标志吗?

使用(或查看)。这是一封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;
                }
            );
        }
    }
}
}
一起去(或看一看)。这是一封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;
                }
            );
        }
    }
}
}

我刚刚在yandex邮箱上尝试了
SentSince
搜索过滤器,但它无法正常工作-返回我所有的电子邮件。不一定是库的错误我只是在yandex邮箱上尝试了
SentSince
搜索过滤器,但它不能正常工作-返回我所有的电子邮件。不一定是图书馆的错