How to Prevent Outlook in Connecting to Office365 Account

Jennifer Agustin
JJ365
Published in
3 min readSep 1, 2019
Photo by Campaign Creators on Unsplash

Issue: Outlook bypasses Autodiscover and directly connects to Office365

Scenario

You are setting up a non-Office365 mailbox or an on-premise Exchange mailbox, but it is detecting your Office365 account even though the Autodiscover is not pointed to Office365.

Cause

Microsoft launched the “Direct Connect to Office365 Feature”(Outlook 2016 version 16.0.6741.2017 and higher) that forces your Outlook 2016 to connect to Office365 when:

  • You have users that are not yet active to Office365 has a mailbox provisioned to it due to Exchange license assigned
  • Autodiscover is not working on the source server.
  • Connection of the computer and the source server is interrupted or blocked by firewall/antivirus

This feature is great since it would automatically detect your Office365 account; however, it can also be a huge problem when you’re in the process of migrating to Office365.

When this happens, email continues to work; however, the user is not going to receive any emails to Outlook since it’s connected to Office365; they receive it to their respective source server.

See this article for more information about “Direct Connect To Office365” Feature: https://docs.microsoft.com/en-us/office365/troubleshoot/administration/unexpected-autodiscover-behavior

Resolution 1

Create a registry entry that excludes your Outlook to detect Office365.

Be careful when modifying the Registry since any changes could potentially cause your computer to not work properly.

Step 1
Open the Registry Editor by typing regedit in the Windows Search or open the run and type regedit.exe

Run regedit.exe in Windows
Run regedit.exe

Note: If you encounter a prompt if you want to allow this device to make changes on your device, click “yes”.

Step 2
Find this location in the regedit:

HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\AutoDiscover
Registry Editor
Registry Editor

Step 3
Create a DWORD (30-bit) value for ExcludeExplicitO365Endpoint and change the value to “1” to enable it.

DWORD (30-bit) value for ExcludeExplicitO365Endpoint
ExcludeExplicitO365Endpoint

Alternatively, you can also do it by running commands in Command Prompt or through Powershell. All of the options work.

Command Prompt

reg add HKEY_CURRENT_USER\Software\Microsoft\Office\x.0\Outlook\AutoDiscover /t REG_DWORD /v ExcludeExplicitO365Endpoint /d 1
Through Command Prompt
Adding Registry Through Command Prompt

Powershell

Set-ItemProperty -Path “HKCU:\Software\Microsoft\Office\16.0\Outlook\AutoDiscover” -Name ‘ExcludeExplicitO365Endpoint’ -Value 1 -Type DWORD –Force
Adding Registry Through Powershell
Adding Registry Through Powershell

Note: You must restart the computer. Any changes to the registry does not take effect without restarting your computer.

Step 3
Create a new Outlook Profile by going to the control panel. It should not see the Office365 mailboxes anymore.

Control Panel > Mail > Show Profiles > Add
Control Panel > Mail > Show Profiles > Add

Notes: Once you’re done migrating to Office365 or all the mailboxes are provisioned and already pointed to Office365, you need to remove this registry; otherwise, it will not set up your Office365 account since it’s set to exclude it.

Resolution 2

Disable MAPI using Exchange Online Powershell

Step 1
Connect to Exchange Online Powershell

Set-ExecutionPolicy RemoteSigned$UserCredential = Get-Credential$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/-Credential $UserCredential -Authentication Basic -AllowRedirectionImport-PSSession $Session

Step 2
Disable the MAPI by running this command:

Set-CASMailbox -Identity $username -MAPIEnabled $false

For more information in Connecting Exchange Online through Powershell, you make check my previous blog:
https://medium.com/jj365/https-medium-com-jj365-connecting-to-office-365-through-powershell-exchange-online-a38f0370fcfe

--

--

Jennifer Agustin
JJ365
Editor for

MCSE Level 2 Cloud Support Engineer for Office365