I’m running a VBA script in Outlook 365. I have several messages selected. When I run the following routine:
Sub FindMessages()
Dim objNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Set objNS = GetNamespace("MAPI")
Set olFolder = objNS.GetDefaultFolder(olFolderInbox)
Debug.Print "Items in Inbox: " & olFolder.Items.Count
Debug.Print "Selected items: " & Application.ActiveExplorer.Selection.Count
End Sub
the output is:
Items in Inbox: 0
Selected items: 6
I just can’t find a way to get the message in Inbox. This will be an automated routine, so I can’t manually select the messages.
I’ve tried various formulations of .GetDefaultFolder(olFolderInbox), but nothing ever shows up.
New contributor
Milton Pope is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.