Tuesday, August 17, 2010

Normalizing Outlook Contact Phone Numbers to E.164 Format

When setting up OCS for Enterprise Voice, it's important to format your Active Directory users' telephone numbers to the E.164 international format, which is +<CountryCode><Area/CityCode><LocalNumber> (see this post by Doug Lawty of Microsoft for more information on why E.164 formatting is important for Enterprise Voice).  For instance, North America's country code is 1, area codes are 3 digits and local numbers are 7 digits, so we get something like +14165551111. 

Ideally, your personal Outlook contacts should also be formatted to the E.164 standard as well.  Outlook 2010 does a better job than previous versions to encourage proper formatting when creating a new contact, but many people will have a lot of legacy contacts that are likely all over the place in terms of formatting.  You can use OCS normalization rules to help deal with getting Outlook contacts to format properly in OCS, but I think its a better idea to fix the source data if at all possible.

Telling your users to manually fix up all their contacts could result in mobs of angry users with pitchforks knocking down your door.  More likely, they just simply won't bother.  To make it easier on users, I've created a VBScript stuffed inside an Exchange Organizational Form that will do the trick nicely.

Create a new blank Organizational Form with instructions on what the form does and a big, fat button on it called NormalizeNumbers (see below for an example).

Click on the View Code button, and paste in this code.  Save it and publish the form.  If all goes well, users should be able to click the button and all the contacts in their default Contacts folder should be updated to E.164 format.  Just in case, they should backup their contacts to another folder.  As always, the code provided is to be used at your own risk.

Good luck!


  1. Does not work, although i fixed the THN error on line 104. Ever tried it out on your own?

  2. Yep, I've installed the form at a dozen or more companies. It's always worked fine. Maybe the text translation from the web screwed something up for you.

  3. Hi Ken,

    This form looks super useful and would like to implement this for my company. When I post the form nothing happens...not sure what I am missing, but there is no indicator that it is running. No contacts are updated either.

    Any guidance would be appreciated.


  4. Hi again. I figured it out. I had to actually name the button NormalizeNumbers.

    Another question for you, our Lync implementors have told us the dial plan cannot filter out the (0) that appears in UK numbers, and as a result any number with the city code (0) fails to dial. Have you run into this issue, and is there anything we can do in the dial plan to fix it? This script doesn't seem to remove that (0), can it be modified to delete it?

  5. Hi Anonymous,
    That script was really North-American centric in its configuration. For it to work better in your environment, try changing the lines that define arrMatchPattern(2) and (3) from this:

    to this


    Change the 011 to 0. That might do what you need. To handle UK international, you might need to add another couple of lines that start off like this:



  6. Hi Ken. Could you do this without using an Org Form? I've basically dealt away with Public Folders as they were not utilized.

  7. There is a typo : (Thn instead of Then):

    If strBusinessFaxNumber <> "" AND bMatchBusFax = vbFALSE Thn Call NormalizePhone(strBusinessFaxNumber, arrMatchPattern(x), arrUpdatePattern(x), bMatchBusFax, bUpdated)