"c# mail retrieve library" Code Answer's

You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "c# mail retrieve library" answered properly. Developers are finding an appropriate answer about c# mail retrieve library related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like c# mail retrieve library. Enter your desired code related query in the search bar and get every piece of information about C# code related question on c# mail retrieve library. 

c# mail retrieve library

By Scary SandpiperScary Sandpiper on Dec 05, 2020
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 ()) {
                using (var cancel = new CancellationTokenSource ()) {
                    client.Connect ("imap.gmail.com", 993, true, cancel.Token);

                    // If you want to disable an authentication mechanism,
                    // you can do so by removing the mechanism like this:
                    client.AuthenticationMechanisms.Remove ("XOAUTH");

                    client.Authenticate ("joey", "password", cancel.Token);

                    // The Inbox folder is always available...
                    var inbox = client.Inbox;
                    inbox.Open (FolderAccess.ReadOnly, cancel.Token);

                    Console.WriteLine ("Total messages: {0}", inbox.Count);
                    Console.WriteLine ("Recent messages: {0}", inbox.Recent);

                    // download each message based on the message index
                    for (int i = 0; i < inbox.Count; i++) {
                        var message = inbox.GetMessage (i, cancel.Token);
                        Console.WriteLine ("Subject: {0}", message.Subject);
                    }

                    // let's try searching for some messages...
                    var query = SearchQuery.DeliveredAfter (DateTime.Parse ("2013-01-12"))
                        .And (SearchQuery.SubjectContains ("MailKit"))
                        .And (SearchQuery.Seen);

                    foreach (var uid in inbox.Search (query, cancel.Token)) {
                        var message = inbox.GetMessage (uid, cancel.Token);
                        Console.WriteLine ("[match] {0}: {1}", uid, message.Subject);
                    }

                    client.Disconnect (true, cancel.Token);
                }
            }
        }
    }
}

Source: stackoverflow.com

Add Comment

0

All those coders who are working on the C# based application and are stuck on c# mail retrieve library can get a collection of related answers to their query. Programmers need to enter their query on c# mail retrieve library related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about c# mail retrieve library for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of c# mail retrieve library while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "c# mail retrieve library". Visit this developer's friendly online web community, CodeProZone, and get your queries like c# mail retrieve library resolved professionally and stay updated to the latest C# updates. 

C# answers related to "c# mail retrieve library"

View All C# queries

C# queries related to "c# mail retrieve library"

Browse Other Code Languages

CodeProZone