Email Setup for Dynamics 365 Queues using IMAP/SMTP

Sending and receiving emails from Dynamics 365 has always been something I’ve found to be a challenge to setup. I recently wanted to have emails sent to an email address get saved to Dynamics 365 as email activities, and for replies to those emails to be sent from within Dynamics 365. A typical scenario for this is a help desk or call center that uses a single email address for sending and receiving all emails. I was able to accomplish this using a Dynamics 365 queue, and to help demystify and remember how to perform this task I’ve documented the steps to follow.

Email Account Setup

In my situation I used an Office 365 Outlook email account, but the same procedures could be taken using any email account that supports IMAP for receiving emails and SMTP for sending emails. With Office 365, the user account that Dynamics 365 will use to connect to the email server is an Active Directory account that authenticates to an Exchange mailbox.

Note: the Active Directory user doesn’t need a Dynamics 365 license assigned to it, as we are configuring a queue to connect to an email account (i.e. we are not setting up a Dynamics 365 user to connect to an email account).

When using an Active Directory account, it needs to be configured so that it can execute within a long-running background process, also commonly referred to as a service account:

  1. Ensure the Active Directory user account’s password has been set to never expire
  2. Ensure the Active Directory user account has been excluded from multi-factor authentication

Email Server Profile Setup

Create an IMAP/SMTP email server profile. This specifies the email server to connect to for sending and receiving emails.

  1. Navigate to Settings -> Email Configuration -> Email Server Profiles
  2. Select the New -> IMAP/SMTP Server menu
  3. Enter the following values in the New Email Server Profile form:
SectionFieldValue
NameEnter an appropriate value
GeneralIncoming Server Locationoutlook.office365.com
GeneralOutgoing Server Locationsmtp.office365.com
AdvancedIncoming Port993
AdvancedOutgoing Port587
  1. Save and Close the record

These Office 365 IMAP and SMTP settings are documented at POP, IMAP, and STMP settings.

Queue Setup

Create a queue that will convert incoming emails to activities. This queue will automatically get a mailbox that we will associate to the previously created email server profile (see the next section). The queue simply specifies the email address to use when connecting to the email server.

  1. Navigate to Settings -> Business Management -> Queues
  2. Select the New menu
  3. Enter the following values:
SectionFieldValue
SummaryNameEnter an appropriate name
SummaryIncoming EmailEnter the email address
  1. Save the record
  2. Once created, the Mailbox record is now listed in the Email Settings section. Open this record.

Mailbox Setup

The mailbox was created automatically when the queue was created. The mailbox needs to be updated to contain the email account’s credentials and to enable and test the email sending/receiving functionality.

  1. Enter the following values:
SectionFieldValue
GeneralAllow to use Credentials for Email ProcessingYes
GeneralUser NameEnter the email address
GeneralPasswordEnter the password
Synchronization MethodServer ProfileSelect the IMAP/SMTP Email Server Profile record created at the beginning of this document
  1. Save the record
  2. Click the Approve Email button. Confirm any popups that appear.
  3. Click the Test & Enable Mailbox button. Confirm any popups that appear.
  4. Open the email account using your email client of choice, and you should see a new test email has been added the sent folder and the inbox.

As you have hopefully seen, there was not a lot to it. Be sure to follow each step in sequence and with the correct values for everything to work.

Leave a comment