README Validate SMTP Addresses

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 #

Azure Entra App Registration #

Delegated permissions:

  • Contacts.Read
  • Mail.Send

Note on scopes: This feature requires only Contacts.Read to check addresses. However, in the demo database AppID=3 (Validate Contacts) shares a single Azure app registration with AppID=4 (Send Email), so Mail.Send is included in the same registration. If you are porting only this validate feature into your own database — without Send Email — register an app with Contacts.Read alone. The Mail.Send scope is only needed because the two features share one registration in the demo.

VBAuth Admin Table – Required Values #

Column NameRequired Value / ExampleNotes
AppID3Identifies this feature’s configuration record
ActionNameVBAuth – Check Contact ExistsDisplay 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
ScopeClaimsMail.Send,Contacts.ReadComma-separated Graph scopes — shared registration with Send Email (AppID=4)
VerbGETHTTP method
URLPart1https://graph.microsoft.com/v1.0/me/contacts?$filter=emailAddresses/any(e:e/address eq 'Base endpoint — email address appended at runtime
URLParameter1Email address to checkURL-encoded at runtime — @ becomes %40
URLPart2')&$select=displayName,emailAddresses&$top=1Filter suffix appended after URLParameter1
URLParameter2NO VALUE REQUIREDNot used
URLPart3NO VALUE REQUIREDNot used
WaitForLogin60Seconds — 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 lngHTTPTimeout in modVBAuthGlobalConstants
  • 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

Updated on April 3, 2026