Integrations · CRM

Validate your Dynamics 365 contacts and leads

Check the email address of every Contact and Lead in Microsoft Dynamics 365 (or Contacts alone in a Dataverse environment without Leads) and keep the result on the record in five columns: a status (valid, invalid, catch_all, unknown or disposable), its reason, the address it belongs to, when it was checked, and why a check got no status. Use them in views, charts and flows like any other column. Download it: email-validation-dynamics-365.zip holds dynamics-365.mjs (the bulk command), the plug-in's source code in plugin/ and the MIT licence.

Two pieces, which work together:

  • The bulk command checks every existing record now. You run it on your own computer; it sends one bulk list for all of them.
  • The plug-in checks new and changed addresses. Dataverse runs it as an asynchronous job after a Contact or Lead is saved, so a save never waits for our API.

Neither ever blocks a save, deletes, deactivates or creates a record. Neither checks an unchanged address twice, except an unknown result, which the bulk command checks again once 24 hours have passed. --revalidate checks every address again, as new checks. What is free: unknown results, malformed addresses, the sandbox test addresses and duplicates in a bulk list. Every other checked address uses one credit.

What you need

  • An API key of ours from the API keys page. For more than 50 records at once it needs the permission Bulk lists (off by default: turn it on when you create the key).
  • In Microsoft Entra ID, an app registration with a client secret.
  • In each environment you use, an application user for that app registration: Power Platform admin center → Manage → Environments → your environment → Settings → Users + permissions → Application users → + New app user. Give it a business unit and a security role that can read and write Contacts and Leads (for the one-time column setup, one that can create columns, for example System Customizer).
  • An unmanaged solution of your own (--solution, its unique name) and its publisher's prefix for the five columns (--prefix, for example cr5a1_). Microsoft recommends a publisher of your own over the default ones.
  • A computer with Node 22.18 or later for the bulk command. Nothing to install: it has no dependencies.
  • For the plug-in: Visual Studio or the dotnet command-line tools to build it, and Windows for Microsoft's Plug-in Registration Tool.

Try it free first

The bulk command checks every record of the tables it reads, one credit each, so never try it on your real records. Use a test environment that holds no real records. A trial environment may come with sample Contacts and Leads: delete them first, or use an environment with none. Add one Contact whose email is no_mailbox@sandbox.email-validation.org (sandbox checks are free; that domain receives no mail, so send it nothing), then run:

cd email-validation-dynamics-365                       # the unzipped folder
export EV_API_KEY=…
export DATAVERSE_URL=https://<your-test-environment>.crm.dynamics.com
export DATAVERSE_TENANT_ID=… DATAVERSE_CLIENT_ID=… DATAVERSE_CLIENT_SECRET=…
node dynamics-365.mjs --setup --tables contact --prefix cr5a1_ --solution YourSolution
node dynamics-365.mjs --tables contact --prefix cr5a1_ --dry-run
node dynamics-365.mjs --tables contact --prefix cr5a1_

The Contact's Email status column says invalid and Email status reason says no_mailbox. With the plug-in registered (below), a new test Contact with that address shows the same once Dataverse has run the plug-in's job. Then delete the test Contact.

Check every existing record

Point DATAVERSE_URL at your real environment. It needs its own application user.

node dynamics-365.mjs --setup --prefix cr5a1_ --solution YourSolution   # once: adds the five columns to Contact and Lead
node dynamics-365.mjs --dry-run --prefix cr5a1_                         # how many records would be checked; free
node dynamics-365.mjs --prefix cr5a1_                                   # checks and writes

Up to 50 records are checked one by one. More go out as one bulk list. If a run stops, run the same command again from the same folder: it resumes the same bulk list and never pays twice (within the 30 days a list is kept). It prints ids and counts, never an address or a secret.

Options:

  • --tables contact or --tables lead: one table only. An environment without a Dynamics 365 app may have no Lead table; use --tables contact there.
  • --prefix: your publisher's prefix (without it, new_).
  • --region eu: checked in the EU, lists and results kept there, with the same key.
  • --revalidate: check again addresses that were checked already.
  • --include-inactive: also deactivated Contacts and qualified or disqualified Leads.

Check new and changed addresses: the plug-in

Build the plug-in assembly from the download's plugin/ folder and sign it with a strong-name key of your own (make one in Visual Studio's Signing tab, with sn -k from Visual Studio's Developer Command Prompt, or use the key pac plugin init makes):

cd plugin
# put your key at src/EmailValidation.Dynamics365.Plugin/plugin.snk (keep it out of any repository)
dotnet build src/EmailValidation.Dynamics365.Plugin -c Release

The build restores Microsoft's Microsoft.CrmSdk.CoreAssemblies package (that means accepting Microsoft's licence for it). The output is plugin/artifacts/bin/EmailValidation.Dynamics365.Plugin/release/EmailValidation.Dynamics365.Plugin.dll.

Register it with Microsoft's Plug-in Registration Tool (pac tool prt, from the Power Platform CLI on Windows):

  1. Register New Assembly: the DLL above, isolation mode Sandbox, location Database.
  2. Register New Step on EmailValidation.Dynamics365.Plugin.EmailCheckPlugin four times: Create and Update on contact, Create and Update on lead. Filter the two Update steps on emailaddress1.
  3. Each step: stage PostOperation, execution mode Asynchronous, and your API key alone as its Secure Configuration (Dataverse shows it only to administrators and never exports it with a solution). Optionally an Unsecure Configuration such as region=eu;prefix=cr5a1_ (the defaults are us and new_).
  4. On each of the two Update steps, Register New Image: a Pre Image named PreImage with the column emailaddress1.

If a check fails, the save has already gone through: the status columns are emptied, Email check error says why (for example timeout), and the next bulk run checks the address again. For an import of thousands of records, turn the four steps off first (Plug-in Registration Tool → the step → Disable), run the bulk command, and turn them back on.

To move it between environments, add the assembly and its steps to a solution. The secure configuration stays behind, so set the key again in each environment.

The five columns

With --prefix cr5a1_ (with no prefix, new_ takes its place):

ColumnHolds
Email status (cr5a1_emailstatus)valid, invalid, catch_all, unknown or disposable
Email status reason (cr5a1_emailreason)the reason, for example no_mailbox or accepted
Email checked address (cr5a1_emailcheckedaddress)the address the status belongs to
Email checked on (cr5a1_emailcheckedon)when the status was written
Email check error (cr5a1_emailcheckerror)why the last check got no status, else empty

Spam traps and complainers are valid with a warning reason: see what each status means.

End the access

Delete the client secret (or the whole app registration) in Microsoft Entra ID and deactivate the application user; unregister the plug-in's steps and assembly in the Plug-in Registration Tool. Delete the API key on our API keys page.

More on Dynamics 365

Updated · Maintained by: Email Validation LLC

Need help? Contact support, or ask the help chat. Something wrong or missing on this page? Tell us