README Check Email Addresses Against Exchange Contacts #
What this does #
Checks one or more SMTP email addresses against the authenticated user’s personal Exchange contacts folder in Microsoft 365, using Microsoft Graph with MFA. The input can be a single address or a comma- or semicolon-separated list. Addresses not found in the contacts folder are reported clearly. The check is advisory only — it does not prevent any action being taken with the addresses.
Note: This checks the user’s personal Exchange mailbox contacts folder only. It does not check the Global Address List or any shared contacts folders.
Office apps #
- Access (tested M365)
- Excel (untested M365)
Required components #
- VBAuth.dll v1.x
- modVBAuthGlobalConstants.bas (from /shared)
- modValidateContacts.bas (this module)
- JSONConverter.bas (Tim Hall VBA-JSON — https://github.com/VBA-tools/VBA-JSON)
Azure Entra App Registration #
Delegated permissions:
- Contacts.Read
- Mail.Send
Note on scopes: This feature requires only
Contacts.Readto check addresses. However, in the demo database AppID=3 (Validate Contacts) shares a single Azure app registration with AppID=4 (Send Email), soMail.Sendis included in the same registration. If you are porting only this validate feature into your own database — without Send Email — register an app withContacts.Readalone. TheMail.Sendscope is only needed because the two features share one registration in the demo.
VBAuth Admin Table – Required Values #
| Column Name | Required Value / Example | Notes |
|---|---|---|
| AppID | 3 | Identifies this feature’s configuration record |
| ActionName | VBAuth – Check Contact Exists | Display name — any value acceptable |
| ClientID | (your App Client ID) | GUID from Azure App Registration Overview blade |
| TenantID | (your Tenant ID) | GUID from Azure App Registration Overview blade |
| ObjectID | (your Object ID) | Set by PopulateMissingObjectIDs |
| ScopeClaims | Mail.Send,Contacts.Read | Comma-separated Graph scopes — shared registration with Send Email (AppID=4) |
| Verb | GET | HTTP method |
| URLPart1 | https://graph.microsoft.com/v1.0/me/contacts?$filter=emailAddresses/any(e:e/address eq ' | Base endpoint — email address appended at runtime |
| URLParameter1 | Email address to check | URL-encoded at runtime — @ becomes %40 |
| URLPart2 | ')&$select=displayName,emailAddresses&$top=1 | Filter suffix appended after URLParameter1 |
| URLParameter2 | NO VALUE REQUIRED | Not used |
| URLPart3 | NO VALUE REQUIRED | Not used |
| WaitForLogin | 60 | Seconds — NB MSXML2 timeout parameters are in milliseconds |
Module: modValidateContacts.bas #
Public functions #
Public Function ValidateContactAddresses(ByVal strTo As String,
ByVal strCC As String,
ByVal strBCC As String,
ByRef strMessage As String) As Boolean
Code language: JavaScript (javascript)
Acquires a bearer token for the configured AppID, then checks each address in strTo, strCC,
and strBCC against the signed-in user’s personal Exchange contacts folder. Each list is
comma- or semicolon-separated. Returns True on completion (even if addresses were not found —
not-found is a result, not a failure). Returns False only on authentication or HTTP error, with
strMessage containing the error detail. On success, strMessage contains a summary stating
either that all addresses were found or listing the not-found addresses grouped by field (To / CC / BCC).
Private functions #
CheckAddressList(strList, ByRef strNotFound, ByRef strErrorMessage) As Boolean — splits a
comma- or semicolon-separated address list and calls ContactExists for each address. Accumulates
not-found addresses into strNotFound.
ContactExists(strEmail, ByRef blnFound, ByRef strErrorMessage) As Boolean — queries the Graph
/me/contacts endpoint for a single email address using the URL-encoded OData filter. Sets
blnFound to True if the address is present in the contacts folder.
Behaviour #
- Each address in the list is checked individually — one HTTP request per address
- A bearer token is acquired once at the start and reused for all subsequent lookups in the same call
- On completion, a message is returned stating either that all addresses were found, or listing the not-found addresses grouped by field (To / CC / BCC)
- A network timeout returns a descriptive error message — timeout duration is controlled by
lngHTTPTimeoutinmodVBAuthGlobalConstants - Requires interactive sign-in — application permissions are not supported
Notes #
- Does not support application permissions
- Does not check the Global Address List
VBAuth, developed and maintained by Andrew Richards (The IT Service Ltd) and Peter Bryant (Corylus Business Systems), © 2025–2026. All rights reserved. https://vbauth.com