That is the correct DASL property tag for Subject (DASL is a query language
used for Advanced Search, among other things).
For the second search I'd write the search term this way to avoid errors:
strF = Chr(34) & "urn:schemas:httpmail:subject"" =
'ToStringTheImpossibleString'"
I would expect no results at all for your debug.print statements, the
AdvancedSearch method call returns right away and you get your results
asynchronously in the AdvancedSearch.Complete event handler.
For your final search term use something like this, always putting single
quotes around any folder name that has a space in it:
Set objSch = Application.AdvancedSearch _
(Scope:="'Deleted Items'", Filter:=strF, SearchSubFolders:=True)
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Wild Bill" wrote in message
...
Below I attempt a search that should succeed, which returns
results.count=0.
Then I attempt a search that should fail; it returns results.count=0.
Then I try to search folder "Deleted Items" which always gives "The
Operation Failed" and Err numbers that vary wildly, though apparently
always negative, e.g. -1386805681, -1352202673, -1317599665 (It does
seem that it's been decreasing as the evening has progressed??!!).
The 1st and 3rd answers bewilder me, and I hoped you could help. BTW, I
am ignorant about "urn:schemas" and confess to have snagged this from
other n/g posts; I assume that it lets me search the subject field.
Worse yet, this is my first time using AdvancedSearch so forgive my
ignorance. I am clear on using Application_AdvancedSearchComplete as
sometimes shown in the n/g, but want to be comfortable with the above
questions first.
OL03. Both noted folders have items as I run this. Neither has a
subfolder.
Sub testSearch()
Dim objSch As Search, strF As String
strF=Chr(34) & "urn:schemas:httpmail:subject"" like 'News'"
Set objSch = Application.AdvancedSearch _
(Scope:="Inbox", Filter:=strF, SearchSubFolders:=True) 'should work
Debug.Print objSch.Results.Count
strF=Chr(34) & "urn:schemas:httpmail:subject"" =
'ToStringTheImpossibleString'"
Set objSch = Application.AdvancedSearch _
(Scope:="Inbox", Filter:=strF, SearchSubFolders:=True) 'should fail
Debug.Print objSch.Results.Count
Set objSch = Application.AdvancedSearch _
(Scope:="Deleted Items", Filter:=strF, SearchSubFolders:=True)
End Sub