问题
I am trying to access all the mails in a given folder via the ActiveX interface to Outlook 2013. I use the message API (MAPI) of Outlook to get the desired folder object.
However, when I go through all the items of this folder object, many messages are missing. Indeed, there are messages that are on the MS Exchange server that are not synchronized with Outlook because they are too old. (In Outlook, the folder ends with a link named 'Click here to view more on Microsoft Exchange'. When clicking on the link, the missing messages appear in Outlook. However they are not added to the folder object after this operation.)
How to access those messages? Is it possible via the Outlook ActiveX interface? If not, is there an equivalent interface to the MS Exchange server?
回答1:
To access older (but not archived) emails, you can either
- Set the Exchange account to sync all items in the Exchange account properties dialog. Outlook must be restarted.
- Set the Exchange account to sync all items programmatically. You can do that using Extended MAPI (C++ or Delphi only), there is a flag that needs to be set in the MSEMS profile section. Redemption (any language) exposes the RDOExchangeMailboxStore.
MonthsToKeepOffline
/DaysToKeepOffline
properties. Outlook must be restarted. - Open the parent folder in the online mode using the MAPI_NO_CACHE flag when calling
IMsgStore::OpenEntry
(Extended MAPI, C++ or Delphi only). Redemption lets you pass that flag when you open the folder using RDOSession.GetFolderFromID
from any language.
来源:https://stackoverflow.com/questions/39595941/programmatically-accessing-archived-mails-in-an-exchange-folder