A Python-based automation system that monitors your Outlook emails, extracts calendar events and dates, stores them in a database, and sends push notifications to your device before important events occur.
- Email Integration: Connects to Microsoft 365/Outlook via OAuth 2.0
- Intelligent Date Extraction: Uses NLP (spaCy) and pattern matching to extract dates and events from email content
- Event Management: SQLite database for storing detected events with confidence scores
- Push Notifications: Firebase Cloud Messaging (FCM) integration for real-time alerts
- Scheduled Processing: Automatically checks emails at configurable intervals
- Logging: Comprehensive logging for debugging and monitoring
- Notification Tracking: Prevents duplicate notifications with
is_notifiedflag
EmailCalendarNotifier (Main Orchestrator)
├── EmailReader (Outlook Integration)
├── DateExtractor (NLP & Pattern Matching)
├── EventManager (SQLite Database)
└── NotificationSystem (Firebase Cloud Messaging)
- Python 3.8+
- Microsoft 365/Outlook account
- Firebase project with Cloud Messaging enabled
- Internet connection
git clone <repository-url>
cd email_notifier# Create virtual environment
python -m venv venv
# Activate virtual environment
.\venv\Scripts\Activate.ps1
# If you get an execution policy error, run:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserpython -m venv venv
venv\Scripts\activate.batpython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtOr install manually:
pip install python-dotenv
pip install sqlalchemy
pip install firebase-admin
pip install spacy
pip install dateparser
pip install schedule
pip install requestspython -m spacy download en_core_web_smHandles OAuth 2.0 authentication and reads emails from Microsoft 365 Outlook.
Methods:
get_unread_emails(): Fetch unread emailsmark_as_read(email_id): Mark email as read
Extracts dates and events from email text using NLP and pattern matching.
Methods:
extract_dates_from_text(text): Extract all dates from email content_extract_by_patterns(text): Regex-based extraction_extract_by_nlp(text): spaCy NLP-based extraction
Manages database operations for storing and retrieving events.
Methods:
add_event(event_data): Store new eventget_upcoming_events(hours): Get events within N hoursmark_as_notified(event_id): Mark event as notifiedget_event_by_id(event_id): Retrieve specific event
Sends push notifications via Firebase Cloud Messaging.
Methods:
send_notification(device_token, title, body, data): Send to single devicesend_topic_notification(topic, title, body, data): Send to topic subscribers
Logs are stored in logs/app.log and console output.
DEBUG: Detailed information for debuggingINFO: General information about application flowWARNING: Warning messages for potential issuesERROR: Error messages for failures
2026-03-27 10:15:30 - INFO - EmailCalendarNotifier initialized successfully
2026-03-27 10:15:31 - INFO - Connected to Outlook email
2026-03-27 10:15:32 - INFO - Extracted 3 events from email
2026-03-27 10:15:33 - INFO - Notification sent successfully: message_id_123
python -m spacy download en_core_web_smpython main.pyfrom main import EmailCalendarNotifier
notifier = EmailCalendarNotifier(device_tokens=["your_tokens"])
notifier.schedule_checks() # Runs indefinitelyCHECK_INTERVAL_MINUTES=1
NOTIFICATION_ADVANCE_HOURS=1
LOG_LEVEL=DEBUGCHECK_INTERVAL_MINUTES=60
NOTIFICATION_ADVANCE_HOURS=48
LOG_LEVEL=WARNINGCreated by Kamva
Last Updated: May 07, 2026