'How to reference server inbox instead of offline inbox?

I want to iterate through my entire Outlook inbox, including messages stored on the MS Exchange Server. However, when I reference my Outlook inbox via:

NameSpace.GetDefaultFolder(olFolderInbox)

It only returns the items in my offline inbox. Does anybody know how to return the entire server archive?

Thanks for your help.



Solution 1:[1]

You need to add something to your ThisOutlookSession (vba) before you are able to perform what you would like to do.

Please refer to the following website. There is a lot explained about connecting to shared folders (exchange) and calendars.

https://www.slipstick.com/developer/working-vba-nondefault-outlook-folders/

Solution 2:[2]

You need to open the folder in the online mode. You can either

  1. Turn cached mode off (not ideal from the performance point of course)

  2. Reopen the folder in the online mode using Extended MAPI (C++ or Delphi only) using IMAPISession::OpenEntry and the MAPI_NO_CACHE (0x0200) flag.

  3. Reopen the folder using Redemption (I am its author - any language) - it exposes (2) above:

    MAPI_NO_CACHE = &H200 
    MAPI_BEST_ACCESS &H10
    set Session = CreateObject("Redemption.RDOSession")
    Session.MAPIOBJECT = Application.Session.MAPIOBJECT
    set vFolder = Session.GetFolderFromID(YourOOMFolder.EntryID, , MAPI_NO_CACHE + MAPI_BEST_ACCESS)
    MsgBox vFolder.Items.Count
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ko_00
Solution 2 Ryan M