The outlook account that I am using has multiple mailboxes set up and although the following answer seems to show how to use the function, I am unable to get this to work as I have multiple mailboxes with the "Inbox" folder. Download attachment from an outlook email using R
To access the relevant folder normally, I would use the below code:
OutApp = COMCreate("Outlook.Application")
outlookNameSpace = OutApp$GetNameSpace("MAPI")
folder = outlookNameSpace$Folders(14)$Folders("Inbox")
It appears I need another line or so, prior to calling the inbox in the below:
search = OutApp$AdvancedSearch("Inbox", "urn:schemas:httpmail:subject = 'test subject'")