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

                string    strContactToDelete = "John Teddy";
                Contact[] contacts           = client.GetContacts(client.MailboxInfo.ContactsUri);
                foreach (Contact contact in contacts)
                {
                    if (contact.DisplayName.Equals(strContactToDelete))
                    {
                        client.DeleteItem(contact.Id.EWSId, DeletionOptions.DeletePermanently);
                    }
                }
                client.Dispose();
                // ExEnd:DeleteContactsFromExchangeServerUsingEWS
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public static void Run()
        {
            try
            {
                string            mailboxUri  = "https://ex2010/ews/exchange.asmx";
                string            username    = "******";
                string            password    = "******";
                string            domain      = "ex2010.local";
                NetworkCredential credentials = new NetworkCredential(username, password, domain);

                // ExStart:UpdateContactInformationUsingEWS
                IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);

                // List all the contacts and Loop through all contacts
                Contact[] contacts = client.GetContacts(client.MailboxInfo.ContactsUri);
                Contact   contact  = contacts[0];
                Console.WriteLine("Name: " + contact.DisplayName);
                contact.DisplayName = "David Ch";
                client.UpdateContact(contact);
                // ExEnd:UpdateContactInformationUsingEWS
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #3
0
        public static void Run()
        {
            try
            {
                // Create instance of IEWSClient class by giving credentials
                IEWSClient client = EWSClient.GetEWSClient("https://exchange.aspose.com/ews/exchange.asmx", "asposeemail.test3", "Aspose2016", "");
                string     id     = client.GetContacts(client.MailboxInfo.ContactsUri)[0].Id.EWSId;

                // ExStart:FetchContactUsingId

                Contact fetchedContact = client.GetContact(id);
                // ExEnd:FetchContactUsingId

                Console.WriteLine("Name: " + fetchedContact.DisplayName);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
コード例 #4
0
        public static void Run()
        {
            try
            {
                // ExStart:GettingContactsUsingEWS
                // Create instance of IEWSClient class by giving credentials
                IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

                // List all the contacts
                Contact[] contacts = client.GetContacts(client.MailboxInfo.ContactsUri);
                foreach (MapiContact contact in contacts)
                {
                    // Display name and email address
                    Console.WriteLine("Name: " + contact.NameInfo.DisplayName + ", Email Address: " + contact.ElectronicAddresses.Email1);
                }
                // ExEnd:GettingContactsUsingEWS
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }