Hi i'm admin in a microsoft exchange workspace and i want to get all mails of the users of this workspace! i found this approach to extract the data, but, is there a possibility to not pass the admin password? instead we can pass like generated credentials or something like that?
from exchangelib import Credentials, Account, Configuration, DELEGATE
userlist = ["[email protected]", "[email protected]", "[email protected]", ...] # Liste des e-mails des utilisateurs
admin_email = "[email protected]"
admin_password = "password" # Le mot de passe de l'admin
credentials = Credentials(username=admin_email, password=admin_password)
for user_email in userlist:
try:
config = Configuration(server='outlook.office365.com', credentials=credentials)
account = Account(primary_smtp_address=user_email, config=config, autodiscover=False, access_type=DELEGATE)
for item in account.inbox.all().order_by('-datetime_received')[:10]:
print(item.subject, item.sender, item.datetime_received)
except Exception as e:
print(f"Erreur lors de l'accès à la boîte aux lettres de {user_email}: {e}")