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 }