एक्सचेंज सर्वर पर वितरण सूचियों के साथ काम करना

वितरण सूचियों के साथ कार्य करना

Aspose.Email API एक्सचेंज सर्वर से वितरण सूचियों को बनाने और पढ़ने की क्षमता प्रदान करता है। वितरण सूचियों को सर्वर पर बनाया जा सकता है तथा सदस्यों को इसका उपयोग करके जोड़ा जा सकता है। IEWSClient. यह लेख दिखाता है कि एक्सचेंज सर्वर पर वितरण सूचियों के साथ कैसे काम किया जाए।

वितरण सूची बनाना

निम्नलिखित कोड स्निपेट दिखाता है कि वितरण सूची कैसे बनाई जाए।

IEWSClient client = EWSClient.getEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList distributionList = new ExchangeDistributionList();
distributionList.setDisplayName("test private list");
MailAddressCollection members = new MailAddressCollection();
members.add("address1@host.com");
members.add("address2@host.com");
members.add("address3@host.com");
client.createDistributionList(distributionList, members);

निजी वितरण सूची प्राप्त करें

निम्नलिखित कोड स्निपेट दिखाता है कि निजी वितरण सूची को कैसे प्राप्त किया जाए।

IEWSClient client = EWSClient.getEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList[] distributionLists = client.listDistributionLists();
for (ExchangeDistributionList distributionList : distributionLists) {
    MailAddressCollection members = client.fetchDistributionList(distributionList);
    for (MailAddress member : (Iterable<MailAddress>) members) {
        System.out.println(member.getAddress());
    }
}

सार्वजनिक वितरण सूची विस्तारित करें

निम्नलिखित कोड स्निपेट दिखाता है कि सार्वजनिक वितरण सूची को कैसे विस्तारित किया जाए।

MailAddressCollection members = client.expandDistributionList(new MailAddress("public.distribution.list@host.com"));
for (MailAddress member : (Iterable<MailAddress>) members) {
    System.out.println(member.getAddress());
}

सदस्य जोड़ना

निजी वितरण सूची में सदस्य जोड़ना

निम्नलिखित कोड स्निपेट दिखाता है कि निजी वितरण सूची में सदस्यों को कैसे जोड़ा जाए।

IEWSClient client = EWSClient.getEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList[] distributionLists = client.listDistributionLists();
MailAddressCollection newMembers = new MailAddressCollection();
newMembers.add("address4@host.com");
newMembers.add("address5@host.com");
client.addToDistributionList(distributionLists[0], newMembers);

लिस्टिंग के बिना सदस्य जोड़ें

निम्नलिखित कोड स्निपेट दिखाता है कि लिस्टिंग के बिना सदस्यों को कैसे जोड़ा जाए।

IEWSClient client = EWSClient.getEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList distributionList = new ExchangeDistributionList();
distributionList.setId("list's id");
distributionList.setChangeKey("list's change key");
MailAddressCollection newMembers = new MailAddressCollection();
newMembers.add("address6@host.com");
client.addToDistributionList(distributionList, newMembers);

निजी वितरण सूची को भेजें

निम्नलिखित कोड स्निपेट दिखाता है कि निजी वितरण सूची को संदेश कैसे भेजा जाए।

ExchangeDistributionList[] distributionLists = client.listDistributionLists();
MailAddress distributionListAddress = distributionLists[0].toMailAddress();
MailMessage message = new MailMessage(new MailAddress("from@host.com"), distributionListAddress);
message.setSubject("sendToPrivateDistributionList");
client.send(message);

सदस्यों को हटाना

निजी वितरण सूची से सदस्यों को हटाना

निम्नलिखित कोड स्निपेट दिखाता है कि निजी वितरण सूची से सदस्यों को कैसे हटाया जाए।

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.addMailAddress(members.get_Item(0));
membersToDelete.addMailAddress(members.get_Item(1));
client.deleteFromDistributionList(distributionLists[0], membersToDelete);

लिस्टिंग के बिना सदस्यों को हटाएँ

निम्नलिखित कोड स्निपेट दिखाता है कि कैसे सदस्यों को लिस्टिंग के बिना हटाया जाए।

IEWSClient client = EWSClient.getEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList distributionList = new ExchangeDistributionList();
distributionList.setId("list's id");
distributionList.setChangeKey("list's change key");
MailAddressCollection membersToDelete = new MailAddressCollection();
MailAddress addressToDelete = new MailAddress("address", true);
// addressToDelete.Id.EWSId = "member's id";
membersToDelete.addMailAddress(addressToDelete);
client.addToDistributionList(distributionList, membersToDelete);

निजी वितरण सूची हटाएँ

निम्नलिखित कोड स्निपेट दिखाता है कि कैसे एक निजी वितरण सूची को हटाया जाए।

IEWSClient client = EWSClient.getEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList[] distributionLists = client.listDistributionLists();
client.deleteDistributionList(distributionLists[0], true);

लिस्टिंग के बिना हटाएँ

निम्न कोड स्निपेट दिखाता है कि बिना सूची बनाये कैसे हटाया जाए।

IEWSClient client = EWSClient.getEWSClient("https://outlook.office365.com/ews/exchange.asmx", "testUser", "pwd", "domain");
ExchangeDistributionList distributionList = new ExchangeDistributionList();
distributionList.setId("list's id");
client.deleteDistributionList(distributionList, true);