Wotcha!
Ok, I'm automating Outlook from VB and I want filter the Inbox (like the Find Items dialog) with some code something like this..
...so that MyClause becomes an SQL LIKE operator..
FindOutlookItem "My Subject"
...runs as...
[Subject] Like '*My Subject*'
The only problem is that both the Restict and Find methods don't like the Like operator (ouch!)
Any idea how just get the items Filtered? There must be a way to do this! - and the M$ documentation doesn't help much - so no change there !
TIA,
Comaboy
Ok, I'm automating Outlook from VB and I want filter the Inbox (like the Find Items dialog) with some code something like this..
Code:
Function FindOutlookItem(strToFind As String)
Dim ol As Object, olns, MyFolder, MyItems, myItem
Set ol = CreateObject("Outlook.Application")
Set olns = ol.GetNameSpace("MAPI")
Set MyFolder = olns.GetDefaultFolder(olFolderInbox)
Set MyItems = MyFolder.Items
MyClause = "[Subject] Like ""*" & strToFind & "*""" ' This is want we want, but it'll throw a tantrum!
Set MyACMEItems = MyItems.Restrict(MyClause)
For Each myItem In MyACMEItems
myItem.Display
Next
End Function
...so that MyClause becomes an SQL LIKE operator..
FindOutlookItem "My Subject"
...runs as...
[Subject] Like '*My Subject*'
The only problem is that both the Restict and Find methods don't like the Like operator (ouch!)
Any idea how just get the items Filtered? There must be a way to do this! - and the M$ documentation doesn't help much - so no change there !
TIA,
Comaboy