If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
AdvancedSearch & PSTs
I need to programmatically create a Search Folder in a PST that includes the
PST's root folder. I can create a Search Folder using AdvancedSearch for any of the PST's subfolders but cannot find folder path string for the root folder that works.. Using the Outlook UI I can create a Search Folder that includes the PST's root folder, so it's possible to do this. Here's the script I'm running in the OutlookSpy Application object's Script tab. Dim scope Dim filter Dim srchFldrName Dim srchSubFldrs Dim srch Dim srchFldr scope = "'\\Personal Folders'" filter = "( http://schemas.microsoft.com/mapi/proptag/0x001A001E Like 'IPM.Post.%' )" srchSubFldrs = true srchFldrName = "TSF - " & Now Debug.Print "Search Folder Name: " + srchFldrName Set srch = Application.AdvancedSearch( scope, filter, srchSubFldrs, srchFldrName ) ' BrowseObject( srch ) If Not srch is Nothing Then Set srchFldr = srch.Save( srchFldrName ) End If If scope is set to just the root folder name, '\\Personal Folders', the call to create the Search object succeeds but the call to save it fails with the following error: Error calling Save() Return code 0x80020009 The operation failed. An object could not be found. Using a scope string such as \\Personal Folders\Top of Information Store causes the call to create the Search object to fail. Does anyone have any suggestions? |
Ads |
#2
|
|||
|
|||
AdvancedSearch & PSTs
Get Inbox.Parent.Name and use that.
-- 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 "Tim Pulley" tpulley_at_mantech-ist_dot_com wrote in message ... I need to programmatically create a Search Folder in a PST that includes the PST's root folder. I can create a Search Folder using AdvancedSearch for any of the PST's subfolders but cannot find folder path string for the root folder that works.. Using the Outlook UI I can create a Search Folder that includes the PST's root folder, so it's possible to do this. Here's the script I'm running in the OutlookSpy Application object's Script tab. Dim scope Dim filter Dim srchFldrName Dim srchSubFldrs Dim srch Dim srchFldr scope = "'\\Personal Folders'" filter = "( http://schemas.microsoft.com/mapi/proptag/0x001A001E Like 'IPM.Post.%' )" srchSubFldrs = true srchFldrName = "TSF - " & Now Debug.Print "Search Folder Name: " + srchFldrName Set srch = Application.AdvancedSearch( scope, filter, srchSubFldrs, srchFldrName ) ' BrowseObject( srch ) If Not srch is Nothing Then Set srchFldr = srch.Save( srchFldrName ) End If If scope is set to just the root folder name, '\\Personal Folders', the call to create the Search object succeeds but the call to save it fails with the following error: Error calling Save() Return code 0x80020009 The operation failed. An object could not be found. Using a scope string such as \\Personal Folders\Top of Information Store causes the call to create the Search object to fail. Does anyone have any suggestions? |
#3
|
|||
|
|||
AdvancedSearch & PSTs
Hi Ken,
I can create a search folder for an Exchange mailbox using '\\Mailbox - UserName' for the scope param (the equivalent of Inbox.Parent.Name). This creates a search folder rooted at the top of the user's mailbox (the "Top of Information Store" folder in MAPI parlance). I want to do the same thing for PSTs. This is a just a plain PST. It doesn't have an Inbox. The folder structure, in Outlook, looks like this Personal Folders | - Deleted Items | - Search Folders | - Folder1 The folder path for the root folder is '\\Personal Folders'. If I use '\\Personal Folders\Folder1' or '\\Personal Folders\Deleted Items' for the AdvancedSearch scope param I can create a search folder. If I use just '\\Personal Folders' for the scope param AdvancedSearch returns a Search object but the call to Search.Save( folderName) fails. If I create a search folder using '\\PersonalFolders\Folder1' for the scope param I can modify it, using the Outlook UI, to search from the root of the PST. I just need to do this programmatically Tim "Ken Slovak - [MVP - Outlook]" wrote in message ... Get Inbox.Parent.Name and use that. -- 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 "Tim Pulley" tpulley_at_mantech-ist_dot_com wrote in message ... I need to programmatically create a Search Folder in a PST that includes the PST's root folder. I can create a Search Folder using AdvancedSearch for any of the PST's subfolders but cannot find folder path string for the root folder that works.. Using the Outlook UI I can create a Search Folder that includes the PST's root folder, so it's possible to do this. Here's the script I'm running in the OutlookSpy Application object's Script tab. Dim scope Dim filter Dim srchFldrName Dim srchSubFldrs Dim srch Dim srchFldr scope = "'\\Personal Folders'" filter = "( http://schemas.microsoft.com/mapi/proptag/0x001A001E Like 'IPM.Post.%' )" srchSubFldrs = true srchFldrName = "TSF - " & Now Debug.Print "Search Folder Name: " + srchFldrName Set srch = Application.AdvancedSearch( scope, filter, srchSubFldrs, srchFldrName ) ' BrowseObject( srch ) If Not srch is Nothing Then Set srchFldr = srch.Save( srchFldrName ) End If If scope is set to just the root folder name, '\\Personal Folders', the call to create the Search object succeeds but the call to save it fails with the following error: Error calling Save() Return code 0x80020009 The operation failed. An object could not be found. Using a scope string such as \\Personal Folders\Top of Information Store causes the call to create the Search object to fail. Does anyone have any suggestions? |
#4
|
|||
|
|||
AdvancedSearch & PSTs
I don't know. I took your code and made it into a macro by putting it in a
Sub and it worked with no errors, and it saved the search as a search folder. I didn't try running it as an OutlookSpy script though. The only change I made to the code was just to put it in the Sub. I tested the code on both Outlook 2007 and 2003. -- 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 "Tim Pulley" tpulley_at_mantech-ist_dot_com wrote in message ... Hi Ken, I can create a search folder for an Exchange mailbox using '\\Mailbox - UserName' for the scope param (the equivalent of Inbox.Parent.Name). This creates a search folder rooted at the top of the user's mailbox (the "Top of Information Store" folder in MAPI parlance). I want to do the same thing for PSTs. This is a just a plain PST. It doesn't have an Inbox. The folder structure, in Outlook, looks like this Personal Folders | - Deleted Items | - Search Folders | - Folder1 The folder path for the root folder is '\\Personal Folders'. If I use '\\Personal Folders\Folder1' or '\\Personal Folders\Deleted Items' for the AdvancedSearch scope param I can create a search folder. If I use just '\\Personal Folders' for the scope param AdvancedSearch returns a Search object but the call to Search.Save( folderName) fails. If I create a search folder using '\\PersonalFolders\Folder1' for the scope param I can modify it, using the Outlook UI, to search from the root of the PST. I just need to do this programmatically Tim |
#5
|
|||
|
|||
AdvancedSearch & PSTs
Ken,
It's working for you because the PST is configured as the default mail delivery location. When the PST is configured as the default mail delivery location the call to save the search succeeds. It fails if the PST is not the default mail delivery. I've tried this on multiple VMs and always get the same result. I originally coded this in C# and as part our apps Outlook add-in and encountered the problem when I started testing. I then tried it as script in OutlookSpy and got the same results. I've tested using PSTs created with Outlook 2003 and Outlook 2007 RTM and SP2 with Outlook 2007 RTM and SP2. "Ken Slovak - [MVP - Outlook]" wrote in message ... I don't know. I took your code and made it into a macro by putting it in a Sub and it worked with no errors, and it saved the search as a search folder. I didn't try running it as an OutlookSpy script though. The only change I made to the code was just to put it in the Sub. I tested the code on both Outlook 2007 and 2003. -- 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 "Tim Pulley" tpulley_at_mantech-ist_dot_com wrote in message ... Hi Ken, I can create a search folder for an Exchange mailbox using '\\Mailbox - UserName' for the scope param (the equivalent of Inbox.Parent.Name). This creates a search folder rooted at the top of the user's mailbox (the "Top of Information Store" folder in MAPI parlance). I want to do the same thing for PSTs. This is a just a plain PST. It doesn't have an Inbox. The folder structure, in Outlook, looks like this Personal Folders | - Deleted Items | - Search Folders | - Folder1 The folder path for the root folder is '\\Personal Folders'. If I use '\\Personal Folders\Folder1' or '\\Personal Folders\Deleted Items' for the AdvancedSearch scope param I can create a search folder. If I use just '\\Personal Folders' for the scope param AdvancedSearch returns a Search object but the call to Search.Save( folderName) fails. If I create a search folder using '\\PersonalFolders\Folder1' for the scope param I can modify it, using the Outlook UI, to search from the root of the PST. I just need to do this programmatically Tim |
#6
|
|||
|
|||
AdvancedSearch & PSTs
I'll have to check again using a non-default PST file.
If you're using Redemption you can directly create a search folder without using AdvancedSearch and saving the search. I don't know if that helps you at all, but it's worth throwing on the table. -- 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 "Tim Pulley" tpulley_at_mantech-ist_dot_com wrote in message ... Ken, It's working for you because the PST is configured as the default mail delivery location. When the PST is configured as the default mail delivery location the call to save the search succeeds. It fails if the PST is not the default mail delivery. I've tried this on multiple VMs and always get the same result. I originally coded this in C# and as part our apps Outlook add-in and encountered the problem when I started testing. I then tried it as script in OutlookSpy and got the same results. I've tested using PSTs created with Outlook 2003 and Outlook 2007 RTM and SP2 with Outlook 2007 RTM and SP2. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Over 500 PSTs on 1 PC | Robbzilla | Outlook - General Queries | 14 | March 19th 09 12:36 AM |
Taking settings across PSTs | John[_11_] | Outlook - General Queries | 9 | January 30th 09 12:29 PM |
Pfbackup corrupts psts. | Celtic | Outlook - General Queries | 10 | February 22nd 08 03:12 PM |
Bloated Archive PSTs | win_cpp | Outlook - General Queries | 5 | October 13th 06 03:36 AM |
Convert pre 2003 Outlook PSTs | Raji A | Outlook - General Queries | 5 | March 29th 06 05:38 PM |