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 message.Value property for every record is null except the first record.
ImapClient ic = new ImapClient("imap-mail.outlook.com", "xxx@hotmail.com", "xxx", ImapClient.AuthMethods.Login, 993, true))
{
ic.SelectMailbox("INBOX");
Lazy<MailMessage>[] messages = ic.SearchMessages(SearchCondition.From("xxx@yahoo.com"));
foreach (Lazy<MailMessage> message in messages)
{
MailMessage m = message.Value;
}
foreach (Attachment attachment in m.Attachments)
{
fileExtension = Path.GetExtension(attachment.Filename);
attachment.Save(@"H:\Demo\" + fileName + Path.GetExtension(attachment.Filename));
}
}
I am not able to understand why. please guide. Thanx.
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.