Restrict

jamie57

Registered User.
Local time
Today, 00:03
Joined
Aug 23, 2002
Messages
15
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.
 
Hmm, solved the problem. Used "" instead of ' , and it seems to work now.
 

Users who are viewing this thread

Back
Top Bottom