Troubleshooting Outlook 2010 AdvancedSearch method

Hello Experts

I am searching for emails in Outlook 2010 from Access 2010 VBA and want to use the AdvancedSearch method.
I know that the email I am searching for exists because I can see it in the Deleted Items folder. However, after at least 30 minutes of searching, AdvancedSearch hasn’t yet found it. The AdvancedSearchComplete event hasn’t yet fired (or if it has I haven’t detected it) and the search result set is empty. After this time, I find it hard to believe that sheer slowness is the problem.
Some more details:

1.      All the action is occurring in the Access class module for my email management form. In the form’s module header, I declare a WithEvents reference to my desktop Outlook instance, which I check is up and running, along with some related stuff:
Private WithEvents molApp As Outlook.Application      ‘ in class module header
Private mblnIsSearchComplete As Boolean   ' set True when email search completes

Private molNS As Outlook.NameSpace
Private molFldrBase As Outlook.Folder
Private WithEvents molFldrInbox As Outlook.Folder
Private WithEvents molFldrDeleted As Outlook.Folder
Private WithEvents molInboxItems As Outlook.Items


2.      In the Form_Open event handler, I set up the necessary references, first to Outlook, which I check is up and running, and then to key email folders:
  Set molApp = GetObject(, "Outlook.Application")  ' will raise error if not already running
   mblnIsSearchComplete = False


   Set molNS = molApp.GetNamespace("MAPI")
   Set molFldrBase = GetOutlookBaseFolder(molNS)  ' instantiate base folder using value(s) in Control table
   Set molFldrInbox = molFldrBase.folders("Inbox")
   Set molFldrDeleted = molFldrBase.folders("Deleted Items")
   Set molInboxItems = molFldrInbox.Items

3.      I have an event handler for the AdvancedSearchComplete event:
Private Sub molApp_AdvancedSearchComplete(ByVal SearchObject As Outlook.Search)
   If SearchObject.Tag = "LostSearch" Then mblnIsSearchComplete = True
End Sub


4.      I am searching on the BIllingInformation field of the email, which for the email in question contains the text “Deleted;4256” without the quotes.

5.      The search parameters are (checked via the immediate window):
a.      strFltr has the value  "urn:schemas:contacts:billinginformation" LIKE '%4256%'
Note that the value actually contains the single and double quotes shown. Adding enclosing quotes would only confuse things.
b.      strScope has the value '\\myfirstname.mylastname@nhs.net\Deleted Items'
Again, the single quotes are literally present and not just setting off a string value

6.      The actual search which doesn’t seem to want to terminate is kicked off by
   Set molSearch = Outlook.AdvancedSearch(strScope, strFltr, False, "LostSearch")

Any ideas what could be wrong? I’d be interested to hear if anyone else has used the Outlook AdvancedSearch method successfully from Access.

Yours hopefully

Kiwi_731
Mark DalleyInformation AnalystAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kyle SantosQuality AssuranceCommented:
Hi,

I am following up on your question.  Do you still need help?

If you solved the problem on your own, would you please post the solution here in case others have the same problem?

Regards,

Kyle Santos
Customer Relations
Mark DalleyInformation AnalystAuthor Commented:
Hi Everyone

I have not found any way of making advanced search faster, and I suspect there isn't one.

I did find a class module ( christened "FastSearch" by its author) which was supposed to help someone else solve a similar problem to the one I am having. When I examined the code, however the way it works was bascally the same as mine, and its speed - at least on the email system I use at work, which is where I need it to work - was equally abysmal.

I would of course be very happy to be proved wrong.

At present, I am finding that it is faster to search the relevant properties directly with VBA rather than entrust it to the AdvancedSearch method.

Kiwi_731
Kyle SantosQuality AssuranceCommented:
Hi,

Thank you for letting me know.  Would you want me to send more alerts out to experts to see if they can assist you with this problem?  Or would you like to delete or just leave it open for now?
Mark DalleyInformation AnalystAuthor Commented:
Please feel free to send out more alerts.

I feel that the main thing lacking is input from someone who can say of AdvancedSearch: This is its overall design, hence best way to use it is X, bearing in mind that it doesn't play well with Y because of Z...

If someone like Sue Mosher or Dmitry Streblechenko could weigh in, that would be just awesome...

Yours hopefully

Kiwi_731
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.