search folder in other pst




I have created a vba function to create and save a new search, which adds
the search into the search folders in outlook. It will place the search into
my default/exchange mailbox. I would like this o be placed in and search
against items in a different store. How can i do this ?? Also i would like to
know how to search the root folder and all sub folders (Basically the whole



below is the code i have been using:

Dim sch As Outlook.Search
Dim rsts As Outlook.Results
Dim i As Integer
blnSearchComp = False
Const strF As String = "urn:schemas:mailheader:subject = 'Test'"
Const strS As String = "Inbox"
Set sch = Application.AdvancedSearch(strS, strF)

sch.Save("Subject Test")

i can set the store the store

Dim objOL As Outlook.Application
Dim objNS As NameSpace
Dim objStore As Store

Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
Set objStore = objNS.Stores(2)

just cant apply it to the search

Ken Slovak - [MVP - Outlook]

What I usually do for that, even in Outlook 2007, is to use the 3rd party
Redemption library ( I use the
RDOStore.SearchRootFolder object for any open store. That returns an
RDOFolder object. I get the Folders collection of the search root as
RDOFolder, which returns an RDOFolders collection, which has an
AddSearchFolder method that returns an RDOSearchFolder object where I can
set up the filters and such for the search folder.

The limitations of that are you need a 3rd party library, the Redemption
search filters can be created using SQL/WebDAV syntax but you have greater
control using Extended MAPI type search conditions, and finally the search
folders created that way aren't visible in the UI.

Other than that I'd open the alternate PST as a default and set up the
search folder and then when the PST is opened as a secondary PST the search
folder will be there and visible.


Thanks for the reply Ken

Unfortunately, its not viable to spend $200 usd on the redemption library to
create 5 or 6 search folders on less than 10 pc's. However it does look very
un professional. I am a bit amazed, dubfounded and defalted, given all the
hype around outlooks intergration with sharepoint, its so easy to do things
via the interface, but impossible to replicate this in any automated fashion.

examples of such, you can link via the connect to outlook option in a
discussion list. But to try and use the stssync protocol to do this via a
script is near impossible, with few to no examples available. ( i havent
found any that explain it yet or how to get the required parameters)

another example, in the outlook interface, right click and create a new
search folder in the sharepoint list, and voila, done. Try in script, and you
need to buy third party add ins and or go to each computer and do some manual
operation to be able to run an automated operation. Whats the point ???

It would be nice of the existing functionality was somehow exposed to



In case anyone ever wants to know another way to do this, try using send keys


SendKeys "^(+P)"
SendKeys "c"
SendKeys "%(h)"

For x = 0 To i
SendKeys "{DOWN}"

Next x
SendKeys "{ }"

SendKeys "{Enter}"
SendKeys "%(e)"
SendKeys "p"
SendKeys "{Enter}"

Hope this helps. Its a bit flakey, but but working

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question