How can I create a multi-tenant Python script to fetch Outlook inbox emails (including attachments) and convert them to JSON?

hasmukh kachhawa 0 Reputation points
2025-05-03T15:05:48.5266667+00:00

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
Microsoft 365 Developer Program
Microsoft 365 Developer Program
Microsoft 365: Formerly Office 365, is a line of subscription services offered by Microsoft which adds to and includes the Microsoft Office product line.Developer Program: A Microsoft program designed to help developers build cross-platform productivity experiences by giving them access to a developer subscription, sample data packs, documentation, training, experts, recommendations, and community events.
201 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.