A Python helper library to automatically manage Outlook auto-reply settings via the Microsoft Graph API.
Project description
Outlook Autoreply Helper
A Python package that automatically manages Outlook auto-reply settings via the Microsoft Graph API. Perfect for scheduling out-of-office messages during vacations or other absences.
Features
- 🔄 Automatic detection of vacation events from your Outlook calendar
- 📅 Smart handling of adjacent or overlapping vacation periods
- ✨ Customizable auto-reply messages using Jinja2 templates
- 🌐 Uses Microsoft Graph API
- 🔑 Persistent token cache for unattended operation
- 🔒 Supports local and Azure Key Vault cache storage
- ☁️ Flexible configuration storage:
- Local machine (environment variables / .env file)
- Azure Key Vault (for unattended server deployments)
- 🔐 Supports multiple authentication flows for initial setup:
- Interactive browser-based authentication
- Device code flow for headless environments
Installation
pip install outlook-autoreply-helper
Alternatively, you can skip the explicit installation and use uv to run the application in an ephemeral Python environment; see below.
Quick Start
-
Register an application in Azure AD:
- Go to Azure Portal > Azure Entra ID > Manage > App registrations.
- Create a new registration "Outlook Autoreply Helper".
- Go to Manage -> Authentication and add the "Mobile and desktop applications" platform.
- Add the redirect URI:
http://localhostto the platform. This is needed for initial authentication when using the Interactive Flow. You do not need this setting if you are using the Device Code Flow. - In the "Implicit grant and hybrid flows" section, ensure that "Access tokens (used for implicit flows)" is selected.
- Add Microsoft Graph API permissions:
Calendars.Read,MailboxSettings.ReadWrite. Ensure you add delegated permissions, not application permissions, as the application needs to access data on behalf of the user. - Note down the Application (client) ID and Directory (tenant) ID.
-
Create a configuration file (
.env):app__tenant_id=<your-tenant-id> app__client_id=<your-client-id> app__auth_flow=interactive # or 'device_code' absence__keyword=Vacation # Keyword to look for in the subject of the calendar event
-
Initialize the application:
outlook-autoreply-helper initYou will be prompted to authenticate and consent to the application accessing your calendar and mailbox settings.
If you are using
uv, you also run the application viauvx outlook_autoreply_helper init
-
Run the application:
outlook-autoreply-helper runThe application will check for upcoming events and update your mailbox settings accordingly.
Again, using
uvthis can also be done viauvx outlook_autoreply_helper run
Configuration
The application supports different options for storing configuration and state (e.g. access tokens) that should be shared between runs.
Local Configuration
Store settings in environment variables or a .env file:
# App Registration Settings
app__tenant_id=<tenant-id>
app__client_id=<client-id>
app__auth_flow=interactive # or 'device_code'
absence__keyword=Vacation # Keyword to look for in the subject of the calendar event
The remaining settings have sensible defaults and can be left out; see .env.example.
By default, the application uses the local file system to store state. For example, access tokens are cached in a local file in the current working directory to reduce the need for re-authentication. See the example in examples/local/.
Using Azure Key Vault for Caches
For unattended server deployments, state that should be shared between runs can be stored in an Azure Key Vault. Just modify the .env file to use the keyvault cache type and provide the URL of the key vault:
...
cache__type=keyvault
cache__keyvault_url=https://<your-keyvault>.vault.azure.net
When you run locally, you may be prompted to login to the Azure account that hosts the key vault. You can do this e.g. via the Azure CLI:
az login
When the application runs in an unattended environment, you need to ensure the application can access the key vault as well. If you are deploying to an Azure Function, then you need to add an appropriate role assignment for the role Key Vault Secrets Officer for the corresponding Function App's managed identity in the key vault's IAM settings.
Note that the Azure tenant that hosts the key vault and the app registration that the application uses to manage the calendar and mailbox settings for a user may reside in different tenants. See examples/az_keyvault_cache/ for an example.
Using Azure Key Vault for Configuration
In addition to storing caches in Azure Key Vault, you can also store all or parts of the configuration there.
Simply set the environment variable AZURE_KEY_VAULT_URL to the URL of the corresponding key vault.
Each setting can then be stored as a secret in the key vault; see the Pydantic documentation for details. This is particularly useful to store the auto-reply templates for unattended operation, since they can still be easily changed by the user without the need to redeploy the application.
See ./examples/az_keyvault_cache_and_settings/ for an example.
Auto-reply Templates
Customize your auto-reply messages using Jinja2 templates. Variables available in templates:
vacation_start: Start date of absencevacation_end: End date of absence
Example template:
I am out of office from {{ vacation_start | date }} to {{ vacation_end | date }}.
I will respond to your message after my return.
The custom filter date formats the date in the desired format. You can change it to any format supported by Python's strftime function via the àbsence__date_format` setting in the configuration:
...
absence__date_format=%Y-%m-%d
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file outlook_autoreply_helper-0.1.2.tar.gz.
File metadata
- Download URL: outlook_autoreply_helper-0.1.2.tar.gz
- Upload date:
- Size: 57.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6c20b6988721ad48722353247bc2c0fd4bd2948f586ddda93fa6fb52ba091df
|
|
| MD5 |
485cd82264479a912973a6d1ba38f39b
|
|
| BLAKE2b-256 |
0fab8ff4b8bbbfcb79ff9b145529951e2aa847253b69462d19464dd83e9104e2
|
Provenance
The following attestation bundles were made for outlook_autoreply_helper-0.1.2.tar.gz:
Publisher:
publish.yml on jenskeiner/outlook-autoreply-helper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
outlook_autoreply_helper-0.1.2.tar.gz -
Subject digest:
a6c20b6988721ad48722353247bc2c0fd4bd2948f586ddda93fa6fb52ba091df - Sigstore transparency entry: 152965075
- Sigstore integration time:
-
Permalink:
jenskeiner/outlook-autoreply-helper@f664d7e1d08835c6856694634992066c39d1ec38 -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/jenskeiner
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f664d7e1d08835c6856694634992066c39d1ec38 -
Trigger Event:
release
-
Statement type:
File details
Details for the file outlook_autoreply_helper-0.1.2-py3-none-any.whl.
File metadata
- Download URL: outlook_autoreply_helper-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
130bd44c03f2ac9972f5d2f2c2b4fc78a6bc05b0f1b6c599323b80aff76fe6cd
|
|
| MD5 |
76958732b2bd909b9d597a441e692b74
|
|
| BLAKE2b-256 |
901937f287faf3b390611a62931e82564e833cb810d8464091bf7bdde26c8412
|
Provenance
The following attestation bundles were made for outlook_autoreply_helper-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on jenskeiner/outlook-autoreply-helper
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
outlook_autoreply_helper-0.1.2-py3-none-any.whl -
Subject digest:
130bd44c03f2ac9972f5d2f2c2b4fc78a6bc05b0f1b6c599323b80aff76fe6cd - Sigstore transparency entry: 152965076
- Sigstore integration time:
-
Permalink:
jenskeiner/outlook-autoreply-helper@f664d7e1d08835c6856694634992066c39d1ec38 -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/jenskeiner
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f664d7e1d08835c6856694634992066c39d1ec38 -
Trigger Event:
release
-
Statement type: