Track Email Message Exchanges Between Salespeople and Contacts

Get more out of the communications between your salespeople and customers by turning email exchanges into actionable opportunities. Business Central can work with Exchange Online to keep a log of the inbound and outbound messages. You can view and analyze the contents of each message on the Interaction Log Entries page.

[!NOTE] In 2022 release wave 1 we've streamlined processes for setting up email logging to increase flexibility and security. If you are a new customer using that version, you're using the new experience. If you're an existing customer, whether you are using the new experience depends on whether your administrator has enabled the the Email logging using the Microsoft Graph API feature update in Feature Management. For more information, see Enabling Upcoming Features Ahead of Time.

[!IMPORTANT] For Business Central and Exchange Online are on the same tenant.

To set up email logging

These steps differ, depending on whether your administrator has turned on the Email logging using the Microsoft Graph API feature update. If the feature update isn't turned on, follow the steps on the Current Experience tab.

Current Experience

Set up Public Folders and Rules for Email Logging in Exchange Online

--- author: edupont04

ms.topic: include ms.date: 02/15/2022 ms.author: edupont

[!NOTE] The following sections assume that you have administrator access for Exchange Online.

Before you can set up email logging, you must prepare Office 365 public folders. You can do this in the Exchange admin center, or you can use the Exchange Online PowerShell.

[!TIP] If you want to use the Exchange Online PowerShell, you can find inspiration for how to set up your script in a sample script that we published in the BCTech repo.

Follow the steps below to set up Exchange Online, with links to where you can learn more.

Create an admin role group

Create an admin role group for public folders based on the information in the following table:

Property Value
Name Public Folders Management
Selected roles Public Folders
Selected users The email of the user account that Business Central will use to run the email logging job

For more information, see Manage role groups in Exchange Online.

Create a new public folder mailbox

Create a new public folder mailbox based on the information in the following table:

Property Value
Name Public MailBox

For more information, see Create a public folder mailbox.

Create new public folders

  1. Create a new public folder with the name Email Logging in the root so that the full path to the folder becomes \Email Logging\.

  2. Create two sub-folders so that the the result is the following full paths to the folders:

    • \Email Logging\Queue\
    • \Email Logging\Storage\

For more information, see Create a public folder.

Set public folder ownership

Set the email logging user as an owner of both public folders, Queue and Storage.

For more information, see Assign permissions to the public folder.

Mail-enable the Queue public folder

For more information, see Mail-enable or mail-disable a public folder.

Mail-enable sending emails to the Queue public folder

Mail-enable sending emails to the Queue public folder using Outlook or the Exchange Management Shell.

For more information, see Allow anonymous users to send email to a mail-enabled public folder.

Create mail flow rules

Create two mail flow rules based on the information in the following table:

Purpose Name Apply this rule if... Do the following...
A rule for incoming email Log Email Sent to This Organization The sender is located Outside the organization, and the recipient is located Inside the organization BCC the email account that is specified for the Queue public folder
A rule for outgoing email Log Email Sent from This Organization The sender is located Inside the organization, and the recipient is located Outside the organization BCC the email account that is specified for the Queue public folder

For more information, see Manage mail flow rules in Exchange Online and Mail flow rule actions in Exchange Online.

[!NOTE] If you make changes in the Exchange Management Shell, the changes become visible in the Exchange admin center after a delay. Also, the changes made in Exchange will be available in Business Central after a delay. The delay might be several hours.

Next, you connect Business Central with Exchange Online.

New Experience

Set Up a Shared Mailbox and Rules for Email Logging in Exchange Online

[!NOTE] These steps require administrator access for Exchange Online.

Prepare a shared mailbox in the Exchange admin center. Alternatively, you can also use Exchange Online PowerShell. For more information, see Create a shared mailbox or Exchange Online PowerShell.

[!NOTE] If you use Exchange Management PowerShell, your changes are available in the Exchange admin center after a delay. The delay might be several hours.

Add a user account for members of the shared mailbox

The account that you'll use for email logging is an Exchange Online account. The scheduled job will use the account to connect to the shared mailbox and process emails. This account should not be associated with a specific person. Add the email account to the members for the shared mailbox. For more information, see Use the EAC to edit shared mailbox delegation.

Allow other users to see logged emails

You can allow another user to open an email message in Exchange that is related to an interaction log entry from Business Central. To do that, give the user Read permission to the Archive folder in the shared mailbox. For more information, see Exchange Online PowerShell.

Create mail flow rules

Mail flow rules look for specific conditions on messages and take action on them. Create two mail flow rules based on the information in the following table. For more information, see Manage mail flow rules in Exchange Online and Mail flow rule actions in Exchange Online.

Purpose Name Apply this rule if... Do the following...
A rule for incoming email Log Email Sent to This Organization The sender is located outside the organization, and the recipient is located inside the organization BCC the email account that is specified for the shared mailbox.
A rule for outgoing email Log Email Sent from This Organization The sender is located inside the organization, and the recipient is located outside the organization. BCC the email account that is specified for the shared mailbox.

[!NOTE] Business Central only processes messages in the Inbox folder in the shared mailbox. If a rule moves messages from the Inbox to another folder, those messages will not be processed. Additionally, messages in the Junk Mails folder are also ignored.


Setting Up Business Central to Log Email Messages

These steps are the same for both the current and new experiences.

Get started with email logging in two easy steps:

  1. Connect Business Central with Exchange Online for your Microsoft 365 subscription. Exchange Online handles your email messages. We've made this step easy by providing an assisted setup guide. You just need your administrator credentials for your administrator account in Microsoft 365. To start the guide, go to the Assisted Setup page, and then select the Set up email logging guide.

  2. Make sure that the email addresses for your sales people and contacts in Business Central are valid. To do that, for each customer or salesperson, open the Contact or Salesperson/Purchaser card and have a look in the Email field.

[!Tip] After you complete the steps in the guide you can check whether the connection was successful. Depending on whether you're using the current or new exerience, do one of the following steps:

  • Current experience: Search for Marketing Setup, choose Access, then Functions, and then Validate Email Logging Setup.
  • New experience: Search for Email Logging, choose Actions, and then choose Validate Setup.

Viewing Email Message Exchanges in the Interaction Log

Business Central creates an entry on the Interaction Log page each time a salesperson and a contact exchange an email message. To view the interaction log, open the Contact card for the person, choose Related, then History, and then Interaction Log Entries. There are a few things you can do with each entry in the log, for example:

  • View the content of the email message that was exchanged by selecting Process and then Show Attachments.
  • Turn an email exchange into a sales opportunity. If an entry looks promising, you can turn it into an opportunity and then manage its progress toward a sale. To turn an email exchange into an opportunity, choose the entry, then Process, and then Create Opportunity. For more information, see Managing Sales Opportunities.

Connecting On-Premises Versions to Microsoft Exchange

You can connect Business Central on-premises to Exchange on-premises or Exchange Online for email logging. For both versions of Exchange, settings for the connection are available on the Marketing Setup page. For Exchange Online, you can also use an assisted setup guide.

[!IMPORTANT] The new experience doesn't support a connection to Exchange on-premises. If you must use Exchange on-premises, do not enable the feature update for the new experience.

Connecting to Exchange On-Premises

Current Experience

To connect Business Central on-premises to Exchange on-premises, on the Marketing Setup page, you can use Basic as the Authentication Type, and then enter credentials for the user account for Exchange on-premises. Then turn on the Enabled toggle to start logging email.

New Experience

The new experience does not support connections to Exchange on-premises.


Connecting to Exchange Online

To connect to Exchange Online you must register an application in Azure Active Directory. Provide the application ID, key vault secret, and the redirect URL to use for the registration. The redirect URL is pre-set and should work for most installations. For more information, see To register an application in Azure AD for connecting from Business Central to Exchange Online.

You must also use OAuth2 as the Authentication Type. You must also register an application in Azure Active Directory. Provide the application ID, key vault secret, and the redirect URL to use for the registration. The redirect URL is pre-populated and should work for most installations. For more information, see To register an application in Azure AD for connecting from Business Central to Exchange Online below.

You must set up your installation to use HTTPS. For more information, see Configuring SSL to Secure the Business Central Web Client Connection. If you're setting up your server to have a different home page, you can change the URL. The client secret will be saved as an encrypted string in your database.

To register an application in Azure AD for connecting from Business Central to Exchange Online

The following steps assume that you use Azure Active Directory to manage identities and access. For more information, see Quickstart: Register an application with the Microsoft identity platform.

Current Experience

The following steps assume that you use Azure Active Directory to manage identities and access. For more information, see Quickstart: Register an application with the Microsoft identity platform. If you do not use Azure Active Directory, see Use Another Identity and Access Management Service.

  1. In the Azure Portal, under Manage, choose Authentication.

  2. Under Redirect URL, add the redirect URL that is suggested on the Marketing Setup page in Business Central. If the redirect URL on the Marketing Setup page is empty, find the suggested redirect URL on the Email Logging Assisted Setup page.

    [!NOTE] If you do not specify the redirect URL, you can do so later by choosing Add a platform, and then choosing Web to add the web application and the redirect URL.

  3. Under Manage, choose Manifest.

  4. Locate the requiredResourceAccess property in the manifest, and add the following code in the brackets ([]) to add the required permissions. For more information, see Register your application.

{
    "resourceAppId": "00000002-0000-0ff1-ce00-000000000000",
    "resourceAccess": [
        {
            "id": "3b5f3d61-589b-4a3c-a359-5dd4b5ee5bd5",
            "type": "Scope"
        },
        {
            "id": "dc890d15-9560-4a4c-9b7f-a736ec74ec40",
            "type": "Role"
        }
    ]
}
  1. Choose Save.

  2. Under Manage, choose API permissions, and then confirm that the following permissions are listed:

    • EWS.AccessAsUser.All
    • full_access_as_app
  3. Under Manage, choose Certificates & Secrets, and then create a new secret for your app. You'll use the secret either in Business Central, in the Client Secret field on the Marketing Setup page, or store it in secure storage and provide it in an event subscriber.

  4. Choose Overview, and then find the Application (client) ID value. The Application (client) ID value is the client ID of your application. You must enter the client ID either on the Marketing Setup page, in the Client ID field, or store it in secure storage and provide it in an event subscriber.

  5. In Business Central, set up email logging on the Marketing Setup page, or use the Email Logging Assisted Setup guide for assistance with the process.

    • Provide the email account of the user on behalf of whom the scheduled job will connect to Exchange Online and process emails. The user must have a valid license for Exchange Online.
    • Provide the URL for your Exchange Online. Typically, this URL is the domain that you specified in the user's email address.
    • Provide the Queue Folder Path and Storage Folder Path.
  6. To start logging email, turn on the Enabled toggle.

  7. Sign in with your administrator account for Azure Active Directory (this account must have a valid license for Exchange and be an administrator in your Exchange Online). After you sign in, you must allow your registered application to sign in to Exchange Online on behalf of the organization. You must give consent to complete the setup.

[!NOTE] If you are not prompted to sign in with your administrator account, it might be because pop ups are blocked. To sign in, allow pop-ups from https://login.microsoftonline.com.

New Experience

  1. In the Azure Portal, under Manage, choose Authentication.

  2. Under Redirect URL, add the redirect URL that is suggested on the Email Logging page in Business Central. If the redirect URL field on the Email Logging page is empty, find the suggested redirect URL on the Assisted Setup page. To open the page, on the Email Logging page, choose Actions, and then Assisted Setup.

    [!NOTE] If you do not specify the redirect URL, you can do so later by choosing Add a platform, and then choosing Web to add the web application and the redirect URL.

  3. Under Manage, choose API permissions, and choose Microsoft Graph, and then choose Delegated permissions.

  4. Use the search box to find and select Mail, and then add the Mail.ReadWrite.Shared permission.

  5. Under Manage, choose Certificates & Secrets, and then create a new secret for your app. You'll use the secret either in the Client Secret field on the Email Logging page in Business Central.

  6. Choose Overview, and then find the Application (client) ID value. This is the client ID of your application. You must enter it either in the Client ID field on the Email Logging page.

  7. In Business Central, set up email logging on the Email Logging page, or use the Assisted Setup guide for assistance.

Use Another Identity and Access Management Service

If you are not using Azure Active Directory to manage identities and access, you will need some help from a developer. If you prefer to store the app ID and secret in a different location, you can leave the Client ID and Client Secret fields blank and write an extension to fetch the ID and secret from the location. You can provide the secret at runtime by subscribing to the OnGetEmailLoggingClientId and OnGetEmailLoggingClientSecret events in codeunit 1641 "Setup Email Logging".


To start logging email

  1. To start logging email, on the Email Logging page, turn on the Enabled toggle.

  2. Sign in with the Exchange Online account that the scheduled job will use to connect to the shared mailbox and process emails.

    [!NOTE] If you are not prompted to sign in the the Exchange Online account, it might be because your browser is blocking pop-ups. To sign in, allow pop-ups from https://login.microsoftonline.com.

To stop logging email

Current Experience

  1. Choose the Lightbulb that opens the Tell Me feature. icon, enter Marketing Setup, and then choose the related link.
  2. Turn off the Enabled toggle.

New Experience

  1. Choose the Lightbulb that opens the Tell Me feature. icon, enter Email Logging, and then choose the related link.
  2. Turn off the Enabled toggle.

To change the user account used for email logging

If you are using the new experience, you can change the user account used for email logging. The current experience doesn't support this.

Current Experience

Disable your current setup, change the user on the Email Logging page, and then re-enable email logging. You can also run the assisted setup guide again.

New Experience

Business Central Online

  1. Sign in to Business Central and Exchange Online.
  2. Choose the Lightbulb that opens the Tell Me feature. icon, enter Email Logging, and then choose the related link.
  3. Choose Related, and then Job Queue Entry.
  4. Restart the Email Logging job.

Business Central On-Premises

  1. Choose the Lightbulb that opens the Tell Me feature. icon, enter Email Logging, and then choose the related link.
  2. Choose Actions, and then Renew Token.
  3. Sign in with the Exchange Online account that the scheduled job will use to connect to the shared mailbox and process emails.

See Also

Managing Relationships

--- author: edupont04

ms.topic: include ms.date: 12/20/2021 ms.author: edupont

Business Central on Microsoft Learn