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

Run() public static method

public static Run ( ) : void
return void
        public static void Run()
        {
            // ExStart:PreFetchMessageSizeUsingIEWSClient
            // Create instance of ExchangeWebServiceClient class by giving credentials
            IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

            // Call ListMessages method to list messages info from Inbox
            ExchangeMessageInfoCollection msgCollection = client.ListMessages(client.MailboxInfo.InboxUri);

            // 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 Size: " + msgInfo.Size);
                Console.WriteLine("==================================");
            }
            // ExEnd:PreFetchMessageSizeUsingIEWSClient
        }
    }
PreFetchMessageSizeUsingIEWSClient