I had a case recently where the customer was using my post for creating a Outlook 2016 profile programmatically and found that the program would hang when performing certain MAPI operations. This only happened when the profile was created programmatically (i.e. not through the Outlook UI or the Mail applet) and the target account was an Outlook.com account. As you may be aware, Outlook.com addresses are being migrated to Exchange as the backend and Extended MAPI can be used to consume them. The root cause of the issue was that Outlook uses the PR_PROFILE_EXCHANGE_CONSUMER_ACCOUNT property to determine if the target account is a "consumer account". If so, certain MAPI operations are avoided. For example, creation of a Global Address Book (GAL). Thus, if you are programmatically creating a MAPI profile that targets an Outlook.com address you need to pre-populate this property yourself. This begs the question, "How do you know if the account is a consumer account?" There are several ways that you can tell: First, you could look at the domain, if it's Outlook.com or Hotmail.com, then chances are high that it's a consumer account. If you want to be 100% sure, you could perform an Autodiscover on the target address and let Exchange tell you. In the Autodiscover response you'll consult the element 'ConsumerMailbox' in the Accounts section of the response. True means that it is, otherwise False. Once you have that data, you'll need to set the PR_PROFILE_EXCHANGE_CONSUMER_ACCOUNT property to what the Autodiscover response was. If the target account is not a consumer account you can omit it completely. You'll need to set this property on the profile section identified as the "EMSMDB Section". You can query for the property PR_PROFILE_EMSMDB_SECTIONID and that'll give you the MAPIUID of this profile section. You must do this before you follow the instructions in my post. Lastly, the profile must be a cached mode profile. This property goes hand in hand with cached mode profiles. Setting this property without indicating that the profile is a cached mode profile will result in undefined behavior.
You'll need to define the property in your application to use it. This property is not included in any of the MAPI headers. I've included that below:
#define PR_PROFILE_EXCHANGE_CONSUMER_ACCOUNT PROP_TAG(0x00B, 0x665e)
At the time of this writing, in order to get the property from Autodiscover, the Exchange Server must think that an Outlook for Windows client is asking for it. Therefore, you must set the User-Agent of the program making the HTTP request to the value that an Outlook for Windows client would use. I'll edit this post when this is addressed.