Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get members of Exchange Distribution List in Python

Using exchangelib, how do you get a list of the members of a Global Distribution List? In the included test case I see how to create and delete a DL within a folder in your Contacts, but not referencing a global DL. I'm open to using a different Python library if necessary.

Update: Here's what I have tried so far. Using this code I'm able to dump a list of my personal Distribution Lists (and other contacts) including the members. I'm thinking I need to "point" my_folder at some sort of global scope to see global Distribution Lists as opposed to those in my personal Contacts.

from exchangelib import DELEGATE, Account, Credentials, Configuration

credentials = Credentials(username='domain\\account', password='passw0rd')
config = Configuration(server='mail.example.com', credentials=credentials)
account = Account(primary_smtp_address='[email protected]', config=config,
              autodiscover=False, access_type=DELEGATE)
my_folder = account.contacts
all_items_without_caching = my_folder.all().iterator()
for item in all_items_without_caching:
    print(item)
like image 453
stdout Avatar asked Jun 28 '17 03:06

stdout


1 Answers

exchangelib author here: the global address book is not implemented in exchangelib yet, unfortunately: https://github.com/ecederstrand/exchangelib/issues/93

EDIT: The GAL folder and FindPeople / GetPersona services are now implemented, so this should work now.

like image 145
Erik Cederstrand Avatar answered Sep 21 '22 17:09

Erik Cederstrand