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

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            try
            {

                // ExStart:ListMessagesByID
                // Create instance of ExchangeClient class by giving credentials
                ExchangeClient client = new ExchangeClient("https://MachineName/exchange/Username", "username", "password", "domain");

                // Call ListMessages method to list messages info from Inbox
                ExchangeMessageInfoCollection msgCollection = client.ListMessagesById(client.MailboxInfo.InboxUri, "[email protected]");

                // Loop through the collection to display the basic information
                foreach (ExchangeMessageInfo msgInfo in msgCollection)
                {
                    Console.WriteLine("Subject: " + msgInfo.Subject);
                    Console.WriteLine("From: " + msgInfo.From.ToString());
                    Console.WriteLine("To: " + msgInfo.To.ToString());
                    Console.WriteLine("Message ID: " + msgInfo.MessageId);
                    Console.WriteLine("Unique URI: " + msgInfo.UniqueUri);
                    Console.WriteLine("==================================");
                }
                // ExEnd:ListMessagesByID
            }
            catch (Exception ex)
            {

                Console.Write(ex.Message);
            }
        }
    }
ListMessagesByID