1

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

此处使用 Java 描述并解决了相同的问题:JavaMail BaseEncode64 错误

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

4

1 回答 1

1

使用(或查看)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;
                }
            );
        }
    }
}
}
于 2012-09-17T12:48:40.813 回答