Adding Global Contacts for an Office 365 Tenant

Exchange Public Folders or Mail Contacts

A recent post to the Office 365 Technical Discussions Facebook group came from a small Office 365 tenant (a voluntary fire brigade with 47 members) who wanted to share global contacts such as the town mayor or local companies. The only solution they had discovered was to create a public folder to hold contacts. This will work, but it’s an Outlook-only solution because Outlook is the only email client that understands how to use the shared contacts from a public folder as an address list (see below)

How contacts stored in an Exchange Online public folder show up in an Outlook address book
The Essential People public folder stores contacts and shows up in Outlook as an address list

Mail Contacts Have Best Client Support

Given the widespread use of mobile devices and the undesirability of setting up and managing public folders in a small Office 365 tenant, mail contacts seem like a better approach. A mail contact is an object created in Exchange for someone outside your organization. Each contact has an email address and other properties that you’d expect to find in an address book, such as first and last name, display name, mailing address, and phone numbers. The email address used for a mail contact must be unique. In other words, it cannot be assigned to another mail-enabled object already known to your organization (including guest user accounts).

Mail contacts are included in the Exchange Global Address List (GAL) and Offline Address Book (OAB), so they are available to all the Microsoft email clients – Outlook desktop (Windows and Mac), OWA, and Outlook for iOS and Android. Because mail contacts exist in the Exchange directory, they are also available to third-party email clients, if those clients choose to include the necessary support (here’s one example that does).

The Downside of Mail Contacts

The downside of mail contacts is that these objects can only be added by an Exchange administrator (or more precisely, an account that has been assigned the Mail Recipients RBAC role). Once your account has the necessary permissions, it can add or update mail contacts using the Office 365 Admin Center (Users – Contacts), the Recipients section of the Exchange Admin Center (EAC), or by running the New-MailContact PowerShell cmdlet.

Adding a new mail contact to Exchange Online via the Office 365 Admin Center
Adding a mail contact through the Office 365 Admin Center

Use PowerShell to Import Contacts from a CSV File

One way to approach the problem is to ask someone who doesn’t have administrative permission to maintain a CSV file holding details of the common contacts. You can add as many of the properties supported by Exchange for mail contacts as you wish. Once the file is ready, PowerShell can process its contents.

A CSV file used to import contacts to Exchange Online
The Input Contacts CSV file

This very simple PowerShell code reads the CSV file shown above and creates a new mail contact for each line found in the file. Note that the New-MailContact cmdlet creates a new mail contact and the Set-Contact cmdlet updates some of the extended properties, like phone numbers.

Free Book about Eradicating Public Folders

If your organization is considering moving from public folders, consider reading the eBook “The Complete Guide to Eradicating Legacy Public Folders” to get some ideas for how you might approach the task.


For more information about public folders, see Chapter 8 of the companion volume for the Office 365 for IT Pros eBook. Mail contacts are covered in Chapter 7 of the main book. You get both the main and companion volumes when you subscribe to Office 365 for IT Pros.

8 Replies to “Adding Global Contacts for an Office 365 Tenant”

  1. I cant get this to work, i finds all the contact in the csv but dosent import them and i get no errors.
    any ideas?

    1. Have you tried running the script in the PowerShell ISE to see what’s happening? Does your account have the mail recipient role that’s needed to add mail contacts?

  2. Hi,
    Im running it in powershell ise and doing it with admin account. But it seems as i get some varieable error.

    1. And what error do you see? It’s kind of hard to debug when you don’t give full details.

      1. Hi, i found the issue i needed to do the import-csv with -Delimiter ‘;’ for it to work.

  3. Very interesting. I wonder what Microsoft plans to do with the Global Address, cause at some levels they support it (Outlook and OWA) and other places not so much (Microsoft Teams). So, for instance a guest user is hidden by default in the GAL and you can’t have a MailContact and MailUser (what a guest user seems to be) with the same SMTP Address. So every contact that is also a guest user in my tenant gets an error when I use your script.

  4. I think this script needs rethinking. It works for contacts that are just that… contacts. I used parts of this script to create 3 addresslists in my organization: All Customers, All Suppliers and All Partners. To facilitate this: CustomAttribute1 contains either “customer”, “supplier” or “partner” and I use a custom addresslist that filters on this property.

    When I run the script, I got errors on several contacts. The error is: The operation couldn’t be performed because object ” couldn’t be found on ‘VI1PR05A001DC06.EURPR05 A001.prod.outlook.com’.

    When I looked further, I found out that all the contacts with errors are guest users in my organisation. When I search for them with Get-Contact or Get-MailContact, I can’t find them. But I do find them when I do a Get-MailUser.

    When I use Set-User and Set-Mailuser to set the properties, I don’t see any changes and no errors.

    And looking in documentation: a guest user is not visible in the GAL by default, but you can make them visible. So, when we start collaborating I can no longer make their contact details like phone numbers, business addresses, etc. visible in the GAL :-S.

    Any Ideas why?

    P.S. I had an error earlier posting this, so I just tried it with another comment 🙂

    1. PowerShell scripts can be adopted to meet your needs. The scripts written here are to illustrate principles, not to be complete solutions for every possible condition in every possible Office 365 tenant. And because you have the code, you can change it to do what you want it to do.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.