✪ Create an Outlook 2016 MAPI Profile with Preconfigured OST using C++
This great article by Dave Vespa explains how to create a new Outlook 2016 profile using MFCMAPI. It even includes a C++ code sample that can be used to automate the task. Unfortunately, I had to make a few modifications to the code before it would compile using Visual Studio 2015 (Community Edition).
Having altered the code, I decided to add support for pre-configuring the MAPI profile to use a specific OST path. I did this so I could take an existing Outlook 2016 OST (generated on a different computer), and insert it into the new profile - a great way to prevent a user from needing to recache their entire mailbox when moving to a new machine!
You can view the source code, download the entire Visual Studio 2015 solution (120KB), or just grab a copy of the statically compiled executable (200KB).
To run the code, you need to provide three arguments: the name of the profile, the email address of the user, and the path to where a blank OST should be created. For example:
profiler.exe Outlook email@example.com c:\users\peter\appdata\local\microsoft\outlook\firstname.lastname@example.org
After running the code, you should be able to replace the empty OST that was created with the user's OST from an existing computer, and then start Outlook using the newly created profile.
Note: To compile the Visual Studio solution you will first need to download the Outlook 2010 MAPI header files. The solution expects the header files to be located under
C:\Office 2010 Developer Resources\Outlook 2010 MAPI Headers. You will also need to grab a copy of EdkGuid.h and EdkMdb.h from the include folder of the MFCMAPI source and add them to the same Outlook 2010 MAPI Headers folder.