This example demonstrates how to download only the headers of a mail message instead of the entire message.
Downloading mail headers only (instead of the entire mail message)
CopyC#
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 in the inbox.
IEnumerable<uint> uids = Client.Search( SearchCondition.All() );
// If we're only interested in the subject line or envelope information, just downloading
// the mail headers is alot cheaper and alot faster.
IEnumerable<MailMessage> messages = Client.GetMessages(uids. FetchOptions.HeadersOnly);
}
}
}
}