Exchange Server'da Dağıtım Listeleri ile Çalışma

Dağıtım Listeleriyle Çalışma

Aspose.Email API, Exchange sunucusundan dağıtım listeleri oluşturma ve okuma yeteneği sağlar. Dağıtım listeleri sunucuda oluşturulabilir ve üyeler ona eklenebilir. IEWSClient. Bu makale, Exchange sunucusunda dağıtım listeleriyle nasıl çalışılacağını gösterir.

Dağıtım Listesi Oluşturma

Aşağıdaki kod bölümü, bir dağıtım listesinin nasıl oluşturulacağını gösterir.

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);

Özel Dağıtım Listesini Getir

Aşağıdaki kod bölümü, özel bir dağıtım listesini nasıl alacağınızı gösterir.

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());
    }
}

Genel Dağıtım Listesini Genişlet

Aşağıdaki kod bölümü, genel dağıtım listesini nasıl genişleteceğinizi gösterir.

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

Üye Ekleme

Özel Dağıtım Listesine Üye Ekleme

Aşağıdaki kod bölümü, özel bir dağıtım listesine üyeleri nasıl ekleyeceğinizi gösterir.

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);

Üyeleri Listelemeden Ekle

Aşağıdaki kod bölümü, üyeleri listelemeden nasıl ekleyeceğinizi gösterir.

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);

Özel Dağıtım Listesine Gönder

Aşağıdaki kod bölümü, özel bir dağıtım listesine nasıl mesaj gönderileceğini gösterir.

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);

Üyeleri Silme

Özel Dağıtım Listesinden Üyeleri Silme

Aşağıdaki kod bölümü, özel bir dağıtım listesinden üyeleri nasıl sileceğinizi gösterir.

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);

Üyeleri Listelemeden Sil

Aşağıdaki kod bölümü, üyeleri listelemeden nasıl sileceğinizi gösterir.

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);

Özel Dağıtım Listesini Sil

Aşağıdaki kod bölümü, özel bir dağıtım listesini nasıl sileceğinizi gösterir.

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

Listelemeden Sil

Aşağıdaki kod örneği, listelemeden nasıl silineceğini gösterir.

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);