How can I create a multi-tenant Python script to fetch Outlook inbox emails (including attachments) and convert them to JSON?
I'm working on a Python project where I want to automate the process of reading emails from Microsoft Outlook inboxes and saving the data (email body, subject, sender, date, etc.) into a JSON file. I also want to download any attachments found in those emails.
The challenge is — this script should not be limited to a single user. I want to build it as a multi-tenant solution, where with the appropriate permission/consent (OAuth or delegated access), the script can access and process inbox data of multiple users from different Microsoft accounts.
Key Requirements:
Support reading emails from multiple Outlook accounts
Store email details in structured JSON format
Automatically download and store attachments
Handle OAuth permissions securely for each user
- Possibly run this as a backend service