I am trying to restrict Outlook sent items to a certain Name or email address. Can someone tell me why this restrict command does not return any results, and what I have to do to get it working?
Set olApp = New Outlook.Application
Set nsNameSpace = olApp.GetNamespace("MAPI")
Set fldFolder = nsNameSpace.GetDefaultFolder(olFolderSentMail)
Set objMessages = fldFolder.Items.Restrict("[To]='Dave Smith'")
.......
I have tried using [Recipients] instead of [To] which made no difference, I also tried using email addresses as well. Nothing returns any results. The rest of the code is just a loop and once I remove the Restrict it shows all the messages in the Sent Items, so the rest of the code is working fine.
Set olApp = New Outlook.Application
Set nsNameSpace = olApp.GetNamespace("MAPI")
Set fldFolder = nsNameSpace.GetDefaultFolder(olFolderSentMail)
Set objMessages = fldFolder.Items.Restrict("[To]='Dave Smith'")
.......
I have tried using [Recipients] instead of [To] which made no difference, I also tried using email addresses as well. Nothing returns any results. The rest of the code is just a loop and once I remove the Restrict it shows all the messages in the Sent Items, so the rest of the code is working fine.