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

Run() public static method

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

                // Get folder URI
                string strFolderURI = string.Empty;
                strFolderURI = client.MailboxInfo.InboxUri;
                strFolderURI = client.MailboxInfo.DeletedItemsUri;
                strFolderURI = client.MailboxInfo.DraftsUri;
                strFolderURI = client.MailboxInfo.SentItemsUri;

                // Get list of messages from the specified folder
                ExchangeMessageInfoCollection msgCollection = client.ListMessages(strFolderURI);
                // ExEnd:ExchangeServerUsingEWS
            }
            catch (Exception ex)
            {

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