Hosted voice mail in Office 365

This article Explains how hosted voice mail works in hybrid environment. Hosted voice mail means voice mail in the cloud (Office 365) because the user’s mailbox is there. Hybrid means the user is using on premise Skype for Business.

To continue reading this article, I assume you know what Exchange UM is, little background about Exchange UM architecture and Exchange UM dial plans, and how Exchange UM voice mail works. Also, check out Part 2 here.

The case is when someone is calling a hosted mailbox user (user with mailbox in Office 365) using on premise Skype for Business infrastructure, and voice mail is to be invoked. The challenge is how the on-premise Skype for Business servers will route the call to Exchange Online (Office 365) and allow the caller to record a voice mail message that is stored on the hosted mailbox (in Office 365).

On-premise Exchange UM servers cannot serve users who are hosted in Office 365. Office 365 mailbox users should use Exchange Online UM features and should be enabled for UM there.

As you can see in the below figure, Alice is either a Skype user or an external caller. She is trying to call Bob on his Skype extension, since he is enabled for on-premise Skype, while his mailbox is hosted in Office 365. The challenge is how would Skype know how and where to route the call if Bob did not answer, and a voice mail to be recorded?

The ideal scenario, is that Alice is calling Bob and Bob is not answering. Skype will then contact Office 365 UM servers, and route the call there, so that Alice can hear Bob’s voice mail greeting, and then record a voice message, that will be stored on Bob Office 365 mailbox.

Hosted voice mail in Office 365 1

Exchange Online UM Issues to solve

When I talk about Skype servers in this article, I mean the on-premise Skype servers and not Skype Online. And when I say hosted user, this means the mailbox is hosted in Office 365.

Hosted users cannot use Exchange UM on-premise. Instead, they should be using Exchange Online UM and to enable UM features for them on Exchange Online. In other words, if your mailbox is hosted in your on-premise Exchange servers, then you can only use the on-premise Exchange UM servers. While if your mailbox is hosted in Exchange Online, then you can only use Exchange Online UM servers.

Saying that, on hybrid model where we have users hosted in Office 365 and others on premise, it is a challenge to have the on-premise Skype servers to route voice mail messages sometimes to Exchange UM on-premise servers, and sometimes to Exchange UM online servers. Moreover, Skype servers should be able to identify that the person to route the call to, has his mailbox on-premise or on Office 365, and thus, route the call accordingly to deliver voice mail capabilities.

There should be a flag in the user AD object that specifies whether Skype will route the voice mail traffic to on premise Exchange UM or to Exchange UM Online. This attribute is called [HostedVoiceMail].

So, when Alice is calling Bob whose mailbox is hosted online, and Bob is not answering his on-premise Skype extension, Skype servers will evaluate for voice mail possibilities. It will do that by inspecting the user’s HostedVoiceMail flag from the user AD object. If it is true, then Skype knows that the user is provisioned for voice mail in Office 365. If it is false, then Skype will start evaluating if the user is provisioned for on premise UM solution by trying to see if he is UM enabled, and what UM dial plan he is member of.

Till not, we have figured out how Skype servers can route to voice mail in the cloud and to voice mail on premise systems. Next, is how will Skype initiate traffic to Exchange Online UM Services? There should be a way for Skype servers to know the server name for Exchange Online UM. This is where HostedVoiceMailPolicy comes to play. It tells Skype servers the DNS name to route the traffic to deliver voice mails in Office 365.

Finally, Skye front end servers do not manage SIP connections outside the corporate network, so there should be a way for the Skype front end servers to ask Skype Edge servers to open SIP traffic to Exchange Online UM. A Hosting provider is Required for the Skype Edge servers to forward voice mail calls to Office 365.

Conditions to make hosted voice mail work

  1. User should have HostedVoiceMail equals to true. This can be done by using Set-CSUser Skype PowerShell Cmdlet.
  2. The user should be enabled for Enterprise Voice on the Skype on-premise implementation.
  3. User should have been assigned HostedVoiceMailPolicy using Set-CSUser . If this value is empty, then the Global HostedVoiceMailPolicy will apply.
  4. Hosting provider Should be defined in Skype for Edge to route traffic to Office 365 using New-CsHostingProvider .
  5. Configure Skype Edge servers for federation and DNS server routing using Set-CsAccessEdgeConfiguration.
  6. Make sure is marked as Authoritative domain in Exchange Online Admin interface and not internal relay, or nothing will work.
  7. Create at least one UM dial plan in Exchange Online.
  8. Enable the user for Exchange Online UM and assign him to UM dial plan.
  9. Connect Office 365 UMmailboxpolicy with an on-premise Exchange UMmailboxpolicy. This will enable us to move already on premise Exchange UM enabled users to Office 365 without first disabling their UM settings, and also preserving the user’s PIN settings.

Step 1

First thing to do is to give a tip to Skype for Business servers that this user has a voice mail in the cloud, so that Skype for Business will not waste time and try to allocate on-premise UM servers to handle the voice mail traffic. This is done by setting HostedVoiceMail attribute for the user to $true.

Set-CSUser –identity “Bob” –hostedvoicemail $true

This will also light the voice mail icon on Skype client for Bob.

Note: You may run into an error when running this command [Set-CsUser : HostedVoiceMail property contains a value that is not recognized by Skype for Business Server.]
This will happen to users that are created after we installed the Skype for Business Server. The command will actually succeed even with this error, so if you run Get-CsUser  you will find that the -HostedVoiceMail  is now $true. The reason why this is happening is mentioned here.

Step 2

Hosted Voice Mail is ONLY supported for users who are Enabled for Skype Enterprise Voice. In order to ensure all voice mail features for users work accurately, you need to ensure they are enabled for Enterprise Voice in your on-premise Skype for Business infrastructure.

Step 3

Now that the Skype for Business knows that Bob has hosted voice mail, the next thing to do is to know how to reach that voice mail. The way to do that is by using something called Hosted Voice Mail Policy. This is nothing but a routing information to tell Skype servers on-premises, how to reach cloud voice mail system.

Hosted Voice Mail Policies are a Skype configuration setting, and like any Skype configuration setting, it can be assigned on global level, site level, and on user level. The good news is that in every organization, there is an existing Global Hosted Voice Mail Policy created in advance for us.

By default, each SIP user is already assigned to the Global Hosted Voice Mail Policy. If we type Get-CSUser  for Bob, and we inspect the HostedVoiceMailPolicy , we will find that it is empty. This means that the user is using the default global hosted voice mail policy.

There can be only on Global hosted voice mail policy in a Skype infrastructure, and in our case, we will just configure it instead of creating user based policy and having to apply it individually to users.

To configure the default Global HostedVoiceMailPolicy:

Set-CshostedVoiceMailPolicy -Identity Global -Description "Global Hosted VM Policy for All Users" -Destination -Organization

Note that:

  • Destination should always be, as this is Office 365 UM service.
  • Organization should be and not

As you can see in the below figure, after running Get-CSUser Claudea | Select *Hosted*  , you can see that a user called Claudea, has been enabled for Hosted Voice Mail, and his HostedVoiceMailPolicy is empty, this means, the Global HostedVoiceMailPolicy will apply to him.

Hosted voice mail in Office 365 2

Step 4

We need to help Skype Edge servers on-premises to route traffic to Office 365. To do that, we need to configure a something called Hosted Provider. This is nothing but a configuration setting in Skype that will help it route calls to Office 365.

When running Get-CSHostingProvider , we found that there is already a hosting provider for both Exchange Online and Lync Online. Now, we will just configure the hosting provider for Exchange Online as per the following:

Hosted voice mail in Office 365 3

It is worth noticing that the previous value for the Exchange Hosting Provider (Verification Level) was AlwaysVerifiable, but we change it to UseSourceVerificationaccording as per Microsoft documentation.

The Proxy FQDN Field should always be pointing to for every customer. The Enabled and EnabledSharedAddressSpace parameters should always be set to TRUE for every customer. Reference article is here.

Step 5

Now it is time to configure the Skype Edge servers to support connecting to Exchange Online.


Set-CsAccessEdgeConfiguration -AllowFederatedUsers $true -EnablePartnerDiscovery $true -UseDnsSrvRouting

Hosted voice mail in Office 365 4

Step 6

Make sure is marked as Authoritative domain in Exchange Online. It took me couple of days trying everything just to find out that it was set to InternalRelay. By default, is configured as authoritative domain. I changed it to Internal Relay because I opened a case with Microsoft regarding Email moderation problem between people in O365 and on premise. The escalation engineer started to talk about arbitration mailboxes and advise us to convert that domain to InternalRelay.

Once we changed the domain back to Authoritative domain, everything starts working. The devil is in the details indeed!

Step 7

Now it is time to create a dial plan in Office 365. This is an easy step, and we decided to create UM dial plans on O365 that matches the name of UM dial plans on premises.

Now, it is not a requirement to have same names between UM dial plans in Office 365 and on premise, but doing that has one and only one advantage that I will discuss here.

As we are in the case of migrating user from Exchange on-premise to Exchange Online, and since the user is already enabled for UM on-premise, then to enable him for UM in Office 365, we have two options.

Option 1: You can disable UM for the user on the on-premise Exchange server and then move his mailbox to Office 365. Then enable him again for UM on Office 365. The reason why you need to disable the UM features for a user before moving him to Exchange Online, is that the you will get an error otherwise, saying that the user is provisioned for Exchange unified messaging, and you have to disable his UM features before proceeding with the move.

Option 2: If you do not wish to disable and re-enable the user for UM and would instead like him to stay UM enabled while you are moving his mailbox, then to do this, you match the names of the UM dial plans and mailbox policies between your on-premise Exchange and Exchange Online. This way, his UM extension and Pin will remain the same. The procedure for this is described very well here.

So How to create the dial plan in Exchange Online using PowerShell? Her is an example:

 New-UMDialplan -Name "LOC801"  -URIType SipName  -NumberOfDigitsInExtension 4   -CountryOrRegionCode 1 -AccessTelephoneNumbers "+88118801"                   

Sleep 10

Set-UMDialPlan -Identity  "LOC801"  -DialByNamePrimary FirstLast  -DialByNameSecondary LastFirst  -PilotIdentifierList  "+88118801"      

Get-UMMailboxPolicy -UMDialPlan "LOC801"  | Set-UMMailboxPolicy -PINLifetime Unlimited

Step 8

From Exchange Online, you can enable the user for Exchange UM.


Now, suppose you have a user with mailbox on-premises. If we want to move his mailbox to Office 365, we need to disable his UM settings, move him to Office 365, and then enable him again in Exchange Online UM.

To move his mailbox without the need to disable his on-premise UM settings, and then enable him for Exchange Online UM, an extra step can be done. For this to work correctly, you need to “map” the UMMailboxPolicy objects in the source forest to the UMMailboxPolicy objects in the target forest

We can avoid that if we have the same name for the UMMailboxPolicy in both source and target environment. Else, we need to do the mapping by running the following command in Exchange Online:

Set-UMMailboxPolicy -identity “Policy B” -SourceForestPolicyNames “Policy A”


Where Policy B is the UMMailboxPolicy in Exchange Online, and Policy A is the UMMailboxPolicy on Exchange on Premise.

Reference Article is here.

Outlook Voice Access and Subscriber Access

To have Outlook Voice Access capabilities for hosted users (in Office 365), we need to assign a subscriber number in each Exchange UM dial plan in Office 365. Each Exchange dial plan should have unique subscriber access number.

Saying that, we need a contact (a.k.a RTC Contact) to be created on-premise to map to each subscriber number we create in Office 365. To do that, two steps need to be done:

  1. Create contact object on premise using New-CsExUmContact
  2. Assign hosted voice mail policy to that contact.

If you read previous related article about how Exchange UM Architecture and Exchange UM voice mail, you know that those contacts are used to map an extension or number to SIP URI, and to enable Skype to discover where to route the traffic going to the subscriber number.

Suppose we have Exchange UM dial plan, with Subscriber Number +9626551333. Now we need to create on our on-premise Active Directory a contact using this command [from Skype on-premise PowerShell]

New-CSExumContact -displaynumber +9626551333 –sipaddress -registrarpool -ou “OU=RTC Special Accounts,OU=Lync Accounts,OU=Service Accounts,OU=Network Management,DC=contoso,dc=com”

Going to AD, we can see that object getting created:

Hosted voice mail in Office 365 5


You can see the display name is an ugly GUID number, but this is fine. Now, remember when we talked about hosted voice mail policy, and we decided not to create one because we will be using the built-in already created default global policy? Well, I am not sure if this default policy will apply to this newly created object, so what I did, is creating a user based hosted voice mail policy and apply it to that contact by running:

New-CsHostedVoicemailPolicy -identity Office365UM -Destination -Description “Office 365 Voicemail” -Organization“”

and then assign it to the created contact:

Grant-cshostedvoicemailpolicy –identity "CN={9522170e-9140-462e-b0f5-5efde255d355},OU=RTC Special Accounts,OU=Lync Accounts,OU=Service Accounts,OU=Network Management,DC=contoso,DC=com" –policyname Office365UM

All looks good, but to change the name of the contact instead of this ugly GUID, I have created the following script to do that:

$DisplayNumber = "+88118801"

$Sipaddress = ""

$Pool = ""

$Description = "O365 EXO Subscriber Access Number [OVA] for 801"

$OU = "OU=MyOu,DC=contoso,DC=com"

$UMContact = New-CSExumContact  -Description $Description  -DisplayNumber $DisplayNumber  -SipAddress $SipAddress  -RegistrarPool  $Pool -OU $OU

Start-Sleep 20

Set-ADObject -Identity $($UMContact.Identity.DistinguishedName)  -DisplayName "Outlook Voice Access $code"

Rename-ADObject -Identity $UMContact.Identity.DistinguishedName  -NewName "Outlook Voice Access $code"

Start-Sleep 20

Grant-CsHostedVoicemailPolicy -Identity "Outlook Voice Access $code" -PolicyName Office365UM

Auto Attendant

This is now an easy one to configure. It is the same as Outlook Voice Access subscriber number, but now when creating the contact object using New-CSExumContact  , we will use the -AutoAttendant $true . Reference article for this command is here.

Reference Articles