Skip to content

A Python script that can be used to extract email PDF attachments from Office 365. Uses Microsoft Graph API.

License

Notifications You must be signed in to change notification settings

berggutcom/Office-365-Email-PDF-Attachment-Extract-Script

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

O365-Email-Attachment-Extractor

This repository contains a Python script that can be used to extract email attachments from Office 365.

I needed a script that could extract PDF attachments of invoices I receive. I found bits and pieces there that didn't work for me hence I decided to bring those bits and pieces together.

To use the script, you will need to create an Azure AD application and grant it permissions to access the Microsoft Graph API. You will also need to install the required Python libraries, such as requests and msal. This script can be useful for automating the extraction of email attachments from Office 365, for example for archiving or backup purposes. Feel free to use, modify, and contribute to this script as needed.

The script uses the Microsoft Graph API to authenticate with Office 365 and retrieve the specified email messages, and then saves the attachments to a local directory.

The script can be customized to extract attachments based on various criteria, such as the sender, recipient, subject, or date range of the email message. It can also be adapted to filter with different types of attachments, including documents, images, and zip files.

In your case depending on your level of access to Azure AD, you may want to use me Graph endpoint instead of users.

#update 09/08/2023 I updated the script to check in Send items all PDF who start with a certain string and save them to local folder. I check the send items only for date today so i can run the script every 2 minutes to get new pdf files saved.

About

A Python script that can be used to extract email PDF attachments from Office 365. Uses Microsoft Graph API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%