Get EXO mail messages via Graph using Python.
Messages are pulled from the inbox of the users.
fileName | Description |
---|---|
Inbox.py | Main script file. Connect to each mailbox listed in the 'users.txt' file and output the messages to the console. |
Requirements.txt | Requirements file listing required modules to be installed in order to run the script. |
users.txt | Txt file with the list of primary smtp addresses of the mailboxes the script will work on. |
config.cfg | Config file. Required lines are: ClientID TenantID ClientSecret authtenant userslistfilename |
config-dev.cfg | A replica of config.cfg file. If exists it will override the config.cfg file. It is listed in the gitignore file, so it should not be pulled to your repository |
- Note that the last line of the config.cfg file, references the text file with the list of email addresses. You can modify this line to map to a different file name.
- You need to have an Azure App registered. If you want to know how to create the app, you can follow these steps.
In my testing I used Windows.
You can open Command Prompt or Powershell and run:
Python.exe inbox.py
it will read the config file, and lookup for the userslistfilename file to fetch the list of mailboxes.
You can pass the email addresses as arguments:
Python.exe inbox.py "user1@contoso.com"
or even:
Python.exe inbox.py "user1@contoso.com","user2@contoso.com"
Passing addresses as arguments, will take precedence even if the line 'userslistfilename' in the config file exists.