0

I would like to search for email with subject "order 14567" in my current Outlook folder.

There is an error (438 - object doesn't support this properties or method.) incurred in the following code:

Set objSch = Application.AdvancedSearch(scope:=strS, _
            Filter:=strF, Tag:=strTag)   

VBA code:

Sub SearchInboxFolder()
'Searches the Inbox
    Dim objSch As Search
    Const strF As String = "urn:schemas:mailheader:subject = 'order 14567'"
    Const strS As String = "Inbox"
    Const strTag As String = "SubjectSearch"
    Set objSch = Application.AdvancedSearch(scope:=strS, _
        Filter:=strF, Tag:=strTag)
End Sub
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
pexpex223
  • 371
  • 4
  • 10
  • 25

1 Answers1

0

It looks like the IsInstantSearchEnabled property of the Store returns false, i.e. the instant search is turned off for the store. In that case you need to use the search string like the following one:

"urn:schemas:mailheader:subject like '%order 14567%'"

You can read about filtering strings in the Filtering Items Using Query Keywords section in MSDN.

Also you may find the Find/FindNext or Restrict methods of the Items class helpful. They are described in depth in the following articles:

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Hi eugene, I change my line to "urn:schemas:mailheader:subject like '%order 14567%'", still not working on Set objSch = Application.AdvancedSearch(scope:=strS, _ Filter:=strF, Tag:=strTag), I was thinkg if i need to add any extra VBA reference? – pexpex223 Mar 01 '15 at 17:07
  • Did you have a chance to check out the the [IsInstantSearchEnabled](https://msdn.microsoft.com/en-us/library/office/ff861239(v=office.15).aspx) property of the Store class? – Eugene Astafiev Mar 01 '15 at 19:28