AE.Net.Mail message.value is null

后端 未结 1 1535
-上瘾入骨i
-上瘾入骨i 2021-01-20 08:43

I am using AE.net.mail for downloading attachments from hotmail account. following is code. Messages array gets all mails according to given condition. The problem is that

相关标签:
1条回答
  • 2021-01-20 09:01

    I would recommend using MailKit instead. It's a much better IMAP client implementation that actually follows the specifications.

    MailKit is built on top of MimeKit which is the best/fastest/most robust MIME parser library for .NET available. It is 25x faster than OpenPOP.NET's parser, 75x faster than SharpMimeTools, 70x faster than Mail.dll, 65x faster than MIMER, and hugely faster than all of the MIME parsers included in all of the open source ImapClient implementations out there (and probably better/faster than the commercial MIME parsers as well).

    Both MimeKit and MailKit are based on tokenizing stream parsers which not only means they are faster than the other libraries, it also means they can better conform to the specs and best of all, it means they do not need to read the entire response from the IMAP server into a huge string buffer before parsing the message - MailKit parses the message directly from the socket which reduces memory usage by a significant amount for large messages.

    using System;
    using System.Net;
    using System.Threading;
    
    using MailKit.Net.Imap;
    using MailKit.Search;
    using MailKit;
    using MimeKit;
    
    namespace TestClient {
        class Program
        {
            public static void Main (string[] args)
            {
                using (var client = new ImapClient ()) {
                    var credentials = new NetworkCredential ("xxx@hotmail.com", "xxx");
                    var uri = new Uri ("imaps://imap-mail.outlook.com");
    
                    using (var cancel = new CancellationTokenSource ()) {
                        client.Connect (uri, cancel.Token);
                        client.Authenticate (credentials, cancel.Token);
    
                        // Open the Inbox folder
                        client.Inbox.Open (FolderAccess.ReadOnly, cancel.Token);
    
                        var query = SearchQuery.FromContains ("xxx@yahoo.com");
                        foreach (var uid in client.Inbox.Search (query, cancel.Token)) {
                            var message = client.Inbox.GetMessage (uid, cancel.Token);
                        }
    
                        client.Disconnect (true, cancel.Token);
                    }
                }
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题