My main PC has developed a few issues, so I have gone back to an older PC. Both are Windows10 with Office 2016. I have copied a complete Access application and for the most part it is functioning correctly.
Except for a routine which reads Emails from a sub folder of my Inbox.
Code:
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookNamespace = OutlookApp.GetNamespace("MAPI")
MsgBox OutlookNamespace.CurrentUser
Set Folder = OutlookNamespace.GetDefaultFolder(olFolderInbox)
Set TOPSFolder = Folder.Folders("TOPS")
TOPSFolder.Items.Sort "[ReceivedTime]", True
i = 1
For Each OutlookMail In TOPSFolder.Items
On my original PC this worked correctly. But on my older PC the For loop exits immediately as it cannot find any mail in the folder but also gives no error (but viewed in Outlook there are at least 40 emails)
As the two systems should be identical I cannot see where to look for the answer.
On both machines the References are te same.
Any clue as to where to look next?