The library RDCOMClient
will be useful for you, here's what I could do on my side:
library(RDCOMClient)
ol <- COMCreate("outlook.Application")
objFolder <- ol$ActiveExplorer()$CurrentFolder()
objFolder$Items()$Count()
# [1] 489
The way it works is not straightforward and the doc of the package is not super easy, but here's how I find my way around it :
Use the VBA
reference : https://learn.microsoft.com/en-us/office/vba/api/outlook.itemproperties
It gives you the object structure, it's sometimes easier to google than to navigate it directly.
Find out how people do it in regular VBA
, and translate it in RDCOMClient
syntax.
For example for this case I found on this link the following vba lines of code :
Set objFolder = Application.ActiveExplorer.CurrentFolder
EmailCount = objFolder.Items.Count
And translated them as shown above.
With a bit of trial and error, looking for existing code and tweaking with the vba reference you will hopefully find your way!