Attachment Issues

How to Detect Existing SharePoint Attachments in an Outlook Add-In

Elise WilliamsElise Williams Oct 23, 2026 868 views

Question details

The user wants to know how to identify if an email attachment in Outlook is already saved in a SharePoint library using an add-in.

How to Detect Existing SharePoint Attachments in an Outlook Add-In
Product
Microsoft Outlook
Device & OS
not provided
Scenario
Developing an Outlook add-in to manage attachments and avoid duplicating files in SharePoint.
Observed behavior
Outlook lacks a native built-in flag to check if an attachment already exists in SharePoint, requiring a custom add-in solution.
Before you start

Ensure you have an active Microsoft 365 developer subscription, access to Microsoft Graph or SharePoint APIs, and a basic understanding of building Outlook web add-ins.

Solution 1Recommended

Build an Outlook Add-In using Microsoft Graph APIs

Use Microsoft Graph API within a custom Outlook add-in to search SharePoint for existing files with matching attachment names.

Since Outlook and VBA do not have a built-in flag to natively detect existing SharePoint files, you must build a custom Office web add-in. By leveraging Microsoft Graph APIs, the add-in can cross-reference the attachment's name or content identifier with the target SharePoint document library.

1
Set up the Add-In project

Use the Yeoman generator for Office Add-ins to scaffold a new Outlook web add-in project.

2
Retrieve attachment details

Use the Office.js API (specifically 'Office.context.mailbox.item.attachments') to fetch the file names and details of the current email attachments.

3
Authenticate the user

Implement the Microsoft Authentication Library (MSAL) or Single Sign-On (SSO) to securely authenticate the user for Microsoft Graph access.

4
Query the SharePoint library

Make an API GET request to the Microsoft Graph SharePoint endpoint (e.g., '/sites/{site-id}/drive/root/search(q='{attachment-name}')') to search the permitted library for the attachment name.

5
Notify the user

Parse the API response data and display an alert or notification in the Outlook add-in task pane if a duplicate file match is found.

Build an Outlook Add-In using Microsoft Graph APIs
VBA Limitations: Relying purely on VBA macro code is not recommended for this task, as it may not reliably authenticate or interact with modern SharePoint Online cloud libraries.
Free Microsoft Office alternative

Looking for a reliable and lightweight Office suite? Try WPS Office

While Outlook and SharePoint integrations require complex Microsoft 365 add-in development, if you just need a powerful, lightweight, and free office suite for your daily document needs, WPS Office is an excellent alternative. It offers high compatibility with Microsoft Office formats without the heavy resource usage.

  1. 1. Download the installer: Visit the official WPS Office website and click the download button for your operating system.
  2. 2. Install the software: Run the downloaded installation file and follow the on-screen prompts to complete the setup.
  3. 3. Start creating documents: Open WPS Office to seamlessly view, edit, and manage your documents, spreadsheets, and presentations.
Free, lightweight, and fast installationFully compatible with Microsoft Word, Excel, and PowerPoint formatsBuilt-in PDF editor and document management toolsFamiliar tabbed interface for managing multiple documents easily
microsoft office alternative - wps office

Frequently Asked Questions

Can I use Outlook rules to detect SharePoint attachments?

No, Outlook rules do not have a built-in condition to check if an attachment exists in a SharePoint library. You must use a custom add-in or set up an automated workflow via Power Automate.

Is it possible to use VBA instead of an Outlook web add-in?

While VBA can perform basic local file operations, it is generally unreliable for detecting files in modern SharePoint Online libraries due to modern authentication requirements and API limitations. A web add-in is the recommended approach.

Which APIs are best for checking SharePoint libraries?

The Microsoft Graph API is the recommended and most secure standard for querying SharePoint document libraries and interacting with Microsoft 365 services from within an Outlook add-in.