We recently resolved a case here where a customer, as part of their larger application, was using SetReceiveFolder to direct messages of their message class to the correct folder so their application could do further processing on them. However, when they tested their application in cached mode, it didn’t work. The SetReceiveFolder call would return S_OK, but the mail would continue to be delivered to the Inbox.

After some investigation, we found that Outlook does not appear to honor SetReceiveFolder settings made on the OST when it synchronizes mail from Exchange. Fortunately, there’s an easy workaround: make the setting on the server instead! Even though this customer was targeting Office 365, which only allows cached mode profiles, it’s still possible to access the server directly to make the call. The trick is to use MAPI_NO_CACHE, as demonstrated here. Once they opened the folder on the server, they were able to make the SetReceiveFolder call and the server would then honor it during message delivery.

Incidentally, we were able to test all of this using MFCMAPI, which has under Tools/Options the switches needed to bypass the cache, and which has the ability to both set receive folders and view the receive folder table. I knew writing that code would pay off!