paint-brush
Email Configuration in Microsoft Dynamics: Linking The Email Field with Outlookby@alicegatsbi
178 reads

Email Configuration in Microsoft Dynamics: Linking The Email Field with Outlook

by Alice GatsbiMay 23rd, 2021
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Email Configuration in Microsoft Dynamics 365 can pose a real problem for CRM users. When you click on the email field in an Account or Contact form within the system, standard Dynamics 365 functionality opens only the default email dialog. When there is no out-of-the-box solution to configure, this becomes a challenge and we've successfully faced it. To activate it we had to perform the following:Open Outlook for the Web in a Chrome tab (you must do this on an Outlook tab) and enter: navigator.registerProtocol Handler(“mailto”,”https://outlook.office.com/mail/deeplink/compose/?mailtouri=%s”)

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Email Configuration in Microsoft Dynamics: Linking The Email Field with Outlook
Alice Gatsbi HackerNoon profile picture

Even if it seems too obvious to write about, Email Configuration in Microsoft Dynamics can pose a real problem for CRM users. This is because when you click on the email field in an Account or Contact form within the system, standard Dynamics 365 functionality opens only the default email dialog.

But what if you don't want to open the Outlook Desktop App or want to open another email service? When there is no out-of-the-box solution to configure, this becomes a challenge and we've successfully faced it.

How It All Began

We wanted to deploy this functionality for a number of reasons.

And before launching our journey we surfed through many forum threads to figure out what other dev trailblazers had already done and what issues they had.

First, we ran into an Ask Different platform discussion:

Then we looked at a Pro Webmasters talk:

So we grasped that the field with the Email entity in CRM invokes the mailto scheme on the client. It determines the schema for email addresses in SMTP (Simple Mail Transfer Protocol).

The mechanism that activates the mail link requires a default mail client to be configured on the user’s computer.

Thus, everything rests on local client settings, which software engineers try to edit in entirely different ways.

Also, we understood that there is going to be a difficulty with the call to Outlook Web App. This is not a physical application, and, therefore, special plugins or separate call commands are needed exactly for this synchronization.

Another concern posed that MS Dynamics 365 didn't offer functionality for tracking the OnClick event by field. To activate it we had to perform the following:

  1. Open Outlook for the Web in a Chrome tab (you must do this on an Outlook tab)
  2. Open your JavaScript console (cmd-opt-j on Mac, ctrl-shift-j on Windows) and enter: navigator.registerProtocolHandler(“mailto”,”https://outlook.office.com/mail/deeplink/compose/?mailtouri=%s”,”Outlook”);
  3. Hit “Allow” in the dialog which comes up.
  4. In Chrome preferences, navigate to chrome://settings/handlers. If Outlook is not already the default handler, click on the “three-dot” menu to the right of the Outlook entry. Pick “Set as default” to make OWA (Outlook Web App) the default handler.

But this method had two disadvantages.

The first one is that it obliged the user to use Google Chrome as the default web client. But, actually, many people don’t like this browser, and, besides that, Apple users will certainly not benefit from this approach.

The second is that it was still a client-place edit. And just imagine that if you have to add such instruction for hundreds, for thousands of users...

What we needed was a much simpler, cohesive approach. And we found one.

How We Actually Synchronized Dynamics 365 CRM with OWA

So, we decided to create our own control (yeah, PCF (PowerApps Component Framework)), with our own onClick-event and transitions.

Even though it was significantly easier and cheaper to write all the necessary actions and transitions right in the custom control code but, we went the extra mile and decided to create a separate functionality (web resource) with a transition option, and another functionality (custom control) will call the web resource we need.

Since we had used React, this helped us install all the necessary components and events, including reacting to OnClick across the field what we think is right.

We created a web page from which the required transition will be made (to a desktop client, to a web application, or simply to open an Email card in Microsoft Dynamics CRM):

let email = Xrm.Page.getAttribute(“emailaddress2”).getValue();

let lastname = Xrm.Page.getAttribute(“firstname”).getValue();

// Web app:

let url = “https://outlook.office.com/?path=/mail/action/compose&to=” + email + “&subject=Test Email&body=Dear ” + firstname;

// Desktop app:

let url = “mailto:” + email + “?subject=Test Email&body=Dear ” + firstname;

// Email CRM

Xrm.Navigation.navigateTo(

{

pageType: “entityrecord”,

entityName: “email”,

createFromEntity: Xrm.Page.data.entity.getEntityReference()

}

We needed to put our control on the form:

We set the necessary attributes (the name of the web resource and the method that will be called). Saved, published, and checked:

As you click on the mail icon, it invokes a custom web resource (form) with three suggestions on how to proceed, so, now users can choose the most preferable email server.

With the help of child attributes, you can send any parameters of the contact card (or account, lead, etc. – no matter what entity you place this functionality on) to call mail.

And, now, you can synchronize email fields in MS Dynamics with any email service of your choice!