繁体   English   中英

AE.Net.Mail Imap部分提取

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM