0

I am trying to retrieve email addresses of a DL in Exchange 2010. I tried code from this url and am getting an error.

https://github.com/ecederstrand/exchangelib

# primary_smtp_address: what should be provided here?
# cred: do we need to provide admin users to retrieve data?

from exchangelib import DELEGATE, Account, Credentials, Configuration
cred = Credentials(username='domain\username',password='xxxx')
config = Configuration(server='exchangeserver.com', credentials=cred)
account = Account(primary_smtp_address='def@xyz.com', config=config, autodiscover=False, access_type=DELEGATE)
for mailbox in account.protocol.epxand_dl('abc@xyz.com'):
    print(mailbox.email_address)

Instead of result am getting below error.

Traceback (most recent call last): File "E:\Sheik-Backup\Sheik-Backup\Workspace\FlaskProject\maillist.py", line 11, in a=Account(...) File "E:\Python Virtual-Env\Development\lib\site-packages\exchangelib\account.py", line 57, in init if '@' not in primary_smtp_address: TypeError: argument of type 'ellipsis' is not iterable

Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63
Sheik Kalidh
  • 33
  • 1
  • 8

1 Answers1

0

A Python Ellipsis (...) is sometimes used as a placeholder for verbose code that would make an example less readable. But it happens to also be valid Python syntax.

Probably, you read an example somewhere using a = Account(...) for brevity, but that's not how you set up an account. You need to replace the ... with arguments that to your account, as described in https://github.com/ecederstrand/exchangelib#setup-and-connecting

Finally, to answer your questions: You need to connect as any user that has permission to call the ExpandDL service on the given DL. That could be a normal user or a special system account, depending on your access restrictions on the Exchange server. primary_smtp_address is the email address of the account you are connecting to.

Erik Cederstrand
  • 9,643
  • 8
  • 39
  • 63