I had another case involving creating a profile to an Office 365 mailbox. However, this time it was for Outlook’s MAPI, not Exchange's MAPI as previously documented. After discussing this with the Outlook product team they agreed to document the minimum number of properties to create a profile using MFCMAPI. Here are the steps. For the non-developers this is not the recommended way to create profiles. It is recommended that you use Outlook to create the profile as the logic for this is all built-in. However, you can use these steps for troubleshooting purposes.
Notes for Developers
In the canonical example of creating a profile, Microsoft shows how to create the service then call IMsgServiceAdmin::ConfigureMsgService() to set the PR_PROFILE_UNRESOLVED_NAME and PR_PROFILE_UNRESOLVED_SERVER properties. However, since Outlook 2010 no longer uses the Global Profile Section this didn’t work for me. What I had to do was to call IMAPIProp::SetProps() on the Exchange Profile Section with the properties above to get the profile to properly connect.
Setting the properties on the profile SHOULD be done before calling MAPILogonEx()
You can avoid being authenticated as well as querying the directory server by not using the “unresolved” properties (e.g. PR_PROFILE_UNRESOLVED_NAME). You can get the information from Autodiscover yourself and populate the values for the following properties.
If you have questions, just add a comment and I will approve them and respond as time permits.