There are several ways you can move categories between mailboxes. The easiest, via an appointment form, does not maintain the category colors. Outlook will assign the colors to each category. If you don't care about the color, this is not an issue. If you only have a few categories where the color matters, it's simple enough to change the colors yourself.
- Add all categories to an appointment, copy it to the calendar in the new mailbox, run the command to Upgrade to color categories.
- Use a macro to export a list of categories and a macro to import the list.
- Use MFCMAPI to export the categories.
- Use Powershell to export and import.
These scripts work with Outlook on your Windows Desktop. To use them, open the PowerShell ISE, paste the script (and edit) then Run. Tip: You can use the "regular" Powershell window, pasting the entire script in at once, but it's easier to edit the file path in the ISE editor.
- On the Windows Start menu, start typing powershell.
- When it comes up, click on Windows PowerShell ISE to open it.
- Paste the desired script in the editor.
- Change the filepath and name as needed. You can save it as a CSV or txt file. Use double quotes around the name if it contains spaces.
- Click Run Script or F5 to run the script.
For these screenshots, I exported my categories then used the delete script to clear them before re-importing.
Export Categories
These scripts create a simple comma-separated list containing the category name, color code, and shortcut. You can edit the list in NotePad before importing it into Outlook.
"Name","Color","ShortcutKey" "Internet Orders","23","0" "Newsletters","3","0" "Outlook MVP","8","0" "MVP","2","0" "GTM","17","0"
Use this script to export the categories in the default account's mailbox.
$outlook = New-Object -ComObject Outlook.Application $namespace = $outlook.GetNamespace("MAPI") $namespace.categories | Select-Object -Property Name, Color, ShortCutKey | Export-Csv -Path D:\Categories.txt -NoTypeInformation -encoding utf8
Use this script if you have more than one account in your profile and want to export the categories from the non-default account. The folder picker dialog comes up - select the account name that you want to export.
$outlook = New-Object -ComObject Outlook.Application $namespace = $outlook.GetNamespace("MAPI") $namespace.PickFolder().Store.Categories | Select-Object -Property Name, Color, ShortCutKey | Export-Csv -Path D:\Categories.txt -NoTypeInformation -encoding utf8
Import Categories
These scripts import the categories from a text file. Note that if the category name exists, the script will return an error on that entry in the PowerShell window but will add any category that does not exist. If you want to change the category colors or shortcuts, you'll need to delete the categories first as the script will not update existing categories.
Use this script to Import categories into the default mailbox.
$outlook = New-Object -ComObject Outlook.Application $namespace = $outlook.GetNamespace("MAPI") Import-CSV "D:\Categories.txt" | ForEach-Object { $namespace.Categories.Add($_.Name,$_.Color,$_.ShortCutKey) }
Use this script to Import the categories into the selected mailbox.
$outlook = New-Object -ComObject Outlook.Application $namespace = $outlook.GetNamespace("MAPI") $sourceStore = $namespace.PickFolder().store Import-CSV "D:\Categories.txt" | ForEach-Object { $sourceStore.Categories.Add($_.Name,$_.Color,$_.ShortCutKey) }
Delete Categories
To delete categories from the list, first export the list then run it to remove all categories from the list. Because this script moves forward, you may need to run it a few times to remove all categories. If the list is in alphabetical order, fewer passes may be needed.
$outlook = New-Object -ComObject Outlook.Application $namespace = $outlook.GetNamespace("MAPI") Import-CSV "D:\Categories.txt" | ForEach-Object { $namespace.Categories.Remove($_.Name) }
Use this to delete the categories from a specific mailbox in your profile.
$outlook = New-Object -ComObject Outlook.Application $source = $namespace.stores | Where-Object { $_.displayname âeq âalias@domain.comâ} Import-CSV "D:\Categories.txt" | ForEach-Object { $source.Categories.Remove($_.Name) }
Outlook Color Category names and index number
Beginning with Outlook 2019/365, Microsoft updated some of the category colors and their names.
Color | Index | Color | Index |
---|---|---|---|
Red | 1 | New: Gray Old: Dark Gray | 14 |
Orange | 2 | New: Dark Gray Old: Black | 15 |
Peach | 3 | Dark Red | 16 |
Yellow | 4 | Dark Orange | 17 |
New: Light Green Old: Green | 5 | New: Brown Old: Dark Peach | 18 |
New: Light Teal Old: Teal | 6 | New: Gold Old: Dark Yellow | 19 |
New: Lime Green Old: Olive | 7 | Dark Green | 20 |
Blue | 8 | New: Teal Old: Dark Teal | 21 |
New: Lavender Old: Purple | 9 | New: Green Old: Dark Olive | 22 |
New: Magenta Old: Maroon | 10 | New: Navy Blue Old: Dark Blue | 23 |
New: Light Gray Old: Steel | 11 | Dark Purple | 24 |
New: Steel Old: Dark Steel | 12 | New: Dark Pink Old: Dark Maroon | 25 |
New: Warm Gray Old: Gray | 13 |
wow, Dianne, you are genius. I like VB scripting and I love Powershell so far I did not know Outlook object model works this simple in Poweshell. Works like a charm. One improvement you add -Encoding UTF8 to the Export-Csv because else it cripples the characters some countries may use. I hope I find more similar nice tricks. I wonder whether you can access user defined fields and whether there are caveats.... Have a nice day
There is a lot your can do with powershell - but also a lot you can't do, at least with fairly simple scripts like these.
Hi Diane, really great, I wanted to use the method with a "note" as described years ago by ExtendOffice, but found out you need complete access to Exchange when it is an Exchange account. This doesn't work in outlook.com. Your scripts imports it into the .ost !
Hi, I see this works through Outlook, but why not just use Outlook itself, which is easier? MFCMAPI is fiddly and weird, but it's easier to teach to support staff than comobject scripting and doesn't error out when you clobber the defaults by pasting in the standards en masse. In order to set, support and maintain company-standard Categories for all Users, the ability to reach into the Exchange Mailbox & manipulate Color Categories there (e.g. to have a standard set of 20 and no others which all users use) is what Admins need. I do the color-category-setting part of the onboarding process now pretty-much the way you describe. It's the hardest part of my job, especially since I've scripted all the rest. I can *pull* categories all day long, and even have a script that warns me when the Users "tinker" with their Color Categories so I'll know to go fix them. Easy-peasy. Putting them in place in the first place? Replacing them when Users tinker? Not-so-much... Is there ANY WAY to reach directly (i.e. on the Exchange Server) into each Mailbox's \Calendar folder to the Associated Contents Table, IPM.Configuration.CategoryList item's PR_ROAMING_XMLSTREAM and set its contents to a standard set?… Read more Âğ
Hi Diane,
Thank you for the information.
I tried to import the category using your script as-is. I created the text file the same as your example and the only thing I have changed was the path with no luck. Hopefully I am missing something here.
Please see below the input and the error:
:
categories.txt is:
PS C:\Windows\system32> $outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace("MAPI")
Import-CSV "G:\kill\outlook\categories.txt" | ForEach-Object {
$namespace.Categories.Add($_.Name,$_.Color,$_.ShortCutKey)
}
Import-CSV : Could not find file 'G:\kill\outlook\categories.txt'.
At line:3 char:1
+ Import-CSV "G:\kill\outlook\categories.txt" | ForEach-Object {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (:) [Import-Csv], FileNotFoundException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ImportCsvCommand
It's saying the file path is wrong - assuming the path is correct, is it open in another product?
Import-CSV : Could not find file 'G:\kill\outlook\categories.txt'.
Hi Diane I wonder is there any way I can copy a few custom calander views that includes conditional formatting to 300 users any advice appreciated.
You can export the views using mfcmapi, but importing them is probably going to be a problem - i don't think you can import using powershell to the exchange server (which would be the easiest way to do it.) I believe Redemption can import, but you need the mailbox open on your computer or redemption on all the computers.