Microsoft Graph API with Maria Barnes

Working with the Microsoft Graph API from VBA: Preparing for the New Outlook (an Access User Group talk with Maria Barnes).

Microsoft Graph API with Maria Barnes

With Microsoft's new web-based Outlook on the horizon, Access developers need alternative solutions for email integration.

In this Access User Group presentation, Maria Barnes demonstrates how to use the Microsoft Graph API to maintain Outlook functionality in Access applications once COM automation support is discontinued. She walks through a complete solution that includes authentication handling, email operations, contact management, and calendar functions—all implemented through VBA code that could be adapted for use in other Office applications.

Whether you're looking to future-proof your Access applications or simply interested in modern API integration techniques, this presentation provides practical code examples and implementation strategies you can start using today.

Background and Motivation

The COM Object Challenge

  • New web-based Outlook will not support COM automation
  • Current COM-based email integration will stop working
  • Affects common tasks like sending PDF reports via email
  • Impacts calendar and contact management features

The Graph API Solution

  • Uses Microsoft's modern web API platform
  • Provides programmatic access to Microsoft 365 services
  • Works independently of Outlook's user interface
  • Supports authentication through Microsoft Entra ID

Technical Implementation

Authentication Setup

  • Register application in Microsoft Entra admin center
  • Obtain client ID and tenant ID
  • Store credentials in application's admin table
  • Handle token acquisition and management
  • Support multiple authentication methods (Edge/IE)

Core Components

  • Base code adapted from Tim Hall's VBA Web API project
  • Custom Graph authenticator class
  • Token management system
  • Error handling for expired tokens
  • Support for multiple API scopes

Key Features

Email Operations

  • Create and send emails
  • Support for HTML formatting
  • Handle file attachments
  • Create draft messages
  • Access sent items

Contact Management

  • Create new contacts
  • List contacts from specific folders
  • Support for custom contact folders
  • Parse contact data from API responses

Calendar Integration

  • Create calendar events
  • Basic event management
  • Support for standard event properties

Implementation Considerations

Limitations

  • Cannot directly open Outlook interface
  • Two-step process for draft messages
  • Size limits on attachments
  • No direct replacement for some COM features

Best Practices

  • Store credentials securely
  • Handle token expiration
  • Manage API permissions carefully
  • Consider client-specific setup requirements

Future Developments

Potential Improvements

  • Enhanced error handling
  • Better token management
  • Additional Graph API features
  • Improved user interface integration

Resources and References

Available Tools

  • Microsoft Graph Explorer
  • API documentation
  • Sample code on GitHub
  • Authentication setup guides

Recording

The full recording is available on YouTube:

Join Live!

Want to get even more out of these presentations? Join the live Access User Group events! The next upcoming events are listed on the AUG Event Calendar.

Attending live gives you the opportunity to:

  • Interact directly with presenters during Q&A sessions
  • Network with other Access developers
  • Share your own experiences and challenges
  • Get immediate answers to your specific questions
  • Participate in group discussions

With multiple user groups across different time zones (and languages!), you're sure to find a meeting time that works for your schedule.

Acknowledgements

  • Base cover image generated by FLUX-schnell
  • Initial draft generated by Claude-3.5-Sonnet

All original code samples by Mike Wolfe are licensed under CC BY 4.0