![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
How can I search emails in PST root folder..? Which folder name I have to pass to the AdvancedSearch method to get the emails from PST root folder..? The following sample code uses the AdvancedSearch method to create a new search that returns all the items in a PST folder that are marked with high importance. If the FolderPath property of the folder contains spaces, use double quotes and single quotes when you set the search filter ("'\PSTFolder\PST SubFolder'", for example). If the FolderPath property of the folder does not contain spaces, you can omit the single quotes. Sub SearchPSTFolder() Dim objSch As Search Dim strF As String Dim strS As String Dim strTag As String 'TODO: Change "\PSTFolder\PST SubFolder" to the PST's FolderPath 'property while omitting the first \ strS = "'\PSTFolder\PST SubFolder'" 'TODO: replace ; with : strF = "urn;schemas:httpmail;importance = 2" strTag = "ImportanceSearch" objSch = objOL.AdvancedSearch(strS, strF, False, strTag) End Sub It is not searching the emails from PST root folder it is searching mails only from PST sub folder. Thanks in Advance...! --------------------- Kolan Veera Reddy |
#3
| |||
| |||
|
|
The Root folder is not available to the Outlook object model except in Outlook 2007. In any case to search folders from one folder to all its subfolders you need to set the SearchSubfolders argument to True, not to False. You can list all the top level folders such as 'Inbox', "Sent Items', etc. and put those in your search string and set the subfolders search on and get all folders that way. -- 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 "Kolan Veera Reddy" <KolanVeeraReddy (AT) discussions (DOT) microsoft.com> wrote in message news:FD1453D8-E6F1-461C-BD2C-3B79716CA27E (AT) microsoft (DOT) com... How can I search emails in PST root folder..? Which folder name I have to pass to the AdvancedSearch method to get the emails from PST root folder..? The following sample code uses the AdvancedSearch method to create a new search that returns all the items in a PST folder that are marked with high importance. If the FolderPath property of the folder contains spaces, use double quotes and single quotes when you set the search filter ("'\PSTFolder\PST SubFolder'", for example). If the FolderPath property of the folder does not contain spaces, you can omit the single quotes. Sub SearchPSTFolder() Dim objSch As Search Dim strF As String Dim strS As String Dim strTag As String 'TODO: Change "\PSTFolder\PST SubFolder" to the PST's FolderPath 'property while omitting the first \ strS = "'\PSTFolder\PST SubFolder'" 'TODO: replace ; with : strF = "urn;schemas:httpmail;importance = 2" strTag = "ImportanceSearch" objSch = objOL.AdvancedSearch(strS, strF, False, strTag) End Sub It is not searching the emails from PST root folder it is searching mails only from PST sub folder. Thanks in Advance...! --------------------- Kolan Veera Reddy |
#4
| |||
| |||
|
|
Hi Slovak, Thanks for your reply, I am using Outlook 2007, In the first post code, i have mentioned False to AdvanceSearch method, actually it is True. For better understanding I am adding some more points. I have created a search object using AdvancedSearch method in outlook object model and saved the search results to "Demo Search" Folder. Please refer the below code. Public Sub Create_SearchFolder(ByVal strRootFolderName As String) 'strRootFolderName is my PST Folder path it ‘contains "\\DemoFolders" ''''''path of PST file'''''' If Not strRootFolderName Is Nothing Then Dim olApp As New Outlook.Application Dim objSch As Microsoft.Office.Interop.Outlook.Search 'Search Query Dim strF As String 'Scope which it is going to search. Dim strS As String Try Dim olSearchFolder As Outlook.MAPIFolder 'Here I am passing strRootFolderName it ‘contains "\\DemoFolders" 'strS = "\\DemoFolders" strS = strRootFolderName Dim strTag As String 'MySearch is the tag for the Search strTag = "MySearch" 'Search query to search the mails which contains strF = "urn:schemas:mailheader:subject = 'Test'" objSch = olApp.AdvancedSearch(strS, strF, True, strTag) 'I am saving the search results to "Demo Search" ‘folder inside search folders olSearchFolder = objSch.Save("Demo Search") Catch ex As System.Exception Throw End Try End If End Sub Instead of strS = "’\\DemoFolders’", if I pass strS = "’MyFolder’" or 'strS = "’Inbox’,'MyFolder1','MyFolder2'" the ’MyFolder1’ and ‘MyFolder2’ are subfolders inside ‘\\Demo Folders’ PST folder. It is working fine and creating "Demo Search" search folder Success fully. It is not creating the search folder for ‘\\Demo Folders'. I need to search the emails in ‘\\Demo Folders’ Root. I have crated a Custom Search Folder using Out of the box properties. It is created search folder successfully and I am able to see the mails in root folder of PST folder. The folder which is named as "Top of Personal Folders" If I pass "’Top of Personal Folders’" to the search method strS = "’Top of Personal Folders’" Search method is throwing exception. I am able to search emails in all subfolders inside the PST folder except in PST root. The PST root is named with "Top of Personal Folders". I am not able to pass the same to search method. How can I search emails in PST root folder..? Which folder name I have to pass to the AdvancedSearch method to get the emails from PST root folder..? -- Kolan Veera Reddy |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |