Exemple #1
0
        public static void Run()
        {
            try
            {
                // Set mailboxURI, Username, password, domain information
                string            mailboxUri  = "https://ex2010/ews/exchange.asmx";
                string            username    = "******";
                string            password    = "******";
                string            domain      = "ex2010.local";
                NetworkCredential credentials = new NetworkCredential(username, password, domain);
                IEWSClient        client      = EWSClient.GetEWSClient(mailboxUri, credentials);

                // ExStart:SendEmailToPrivateDistributionList

                ExchangeDistributionList[] distributionLists = client.ListDistributionLists();
                MailAddress distributionListAddress          = distributionLists[0].ToMailAddress();
                MailMessage message = new MailMessage(new MailAddress("*****@*****.**"), distributionListAddress);
                message.Subject = "sendToPrivateDistributionList";
                client.Send(message);
                // ExEnd:SendEmailToPrivateDistributionList
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #2
0
        public static void Run()
        {
            // ExStart:DeletePrivateDistributionList
            IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

            ExchangeDistributionList[] distributionLists = client.ListDistributionLists();
            client.DeleteDistributionList(distributionLists[0], true);
            // ExEnd:DeletePrivateDistributionList
        }
        public static void Run()
        {
            // ExStart:AddMembersToPrivateDistributionList
            IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

            ExchangeDistributionList[] distributionLists = client.ListDistributionLists();
            MailAddressCollection      newMembers        = new MailAddressCollection();

            newMembers.Add("*****@*****.**");
            newMembers.Add("*****@*****.**");
            client.AddToDistributionList(distributionLists[0], newMembers);
            // ExEnd:AddMembersToPrivateDistributionList
        }
Exemple #4
0
        public static void Run()
        {
            // ExStart:DeleteMembersFromPrivateDistributionList
            IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

            ExchangeDistributionList[] distributionLists = client.ListDistributionLists();
            MailAddressCollection      members           = client.FetchDistributionList(distributionLists[0]);
            MailAddressCollection      membersToDelete   = new MailAddressCollection();

            membersToDelete.Add(members[0]);
            membersToDelete.Add(members[1]);
            client.DeleteFromDistributionList(distributionLists[0], membersToDelete);
            // ExEnd:DeleteMembersFromPrivateDistributionList
        }
        public static void Run()
        {
            // ExStart:FetchPrivateDistributionList
            IEWSClient client = EWSClient.GetEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");

            ExchangeDistributionList[] distributionLists = client.ListDistributionLists();
            foreach (ExchangeDistributionList distributionList in distributionLists)
            {
                MailAddressCollection members = client.FetchDistributionList(distributionList);
                foreach (MailAddress member in members)
                {
                    Console.WriteLine(member.Address);
                }
            }
            // ExEnd:FetchPrivateDistributionList
        }