Aspose.Email.Examples.CSharp.Email.Exchange.ConnectExchangeServerUsingIMAP.Run C# (CSharp) Method

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:ConnectExchangeServerUsingIMAP
            // Connect to Exchange Server using ImapClient class
            ImapClient imapClient = new ImapClient("ex07sp1", "Administrator", "Evaluation1");
            imapClient.SecurityOptions = SecurityOptions.Auto;

            // Select the Inbox folder
            imapClient.SelectFolder(ImapFolderInfo.InBox);

            // Get the list of messages
            ImapMessageInfoCollection msgCollection = imapClient.ListMessages();
            foreach (ImapMessageInfo msgInfo in msgCollection)
            {
                Console.WriteLine(msgInfo.Subject);
            }
            // Disconnect from the server
            imapClient.Dispose();
            // ExEnd:ConnectExchangeServerUsingIMAP
        }
    }
ConnectExchangeServerUsingIMAP