VBScript to Create Outlook Search Folder
Hey
Im not really very good with vbs, but i found a post on this forum for creating an outlook search folder. i think its for vb... is there a way to make this work with vbs?
Code:
Option Explicit
'Add reference to MS Outlook 11.0 Object Library
Private Sub Command1_Click()
Dim oApp As Outlook.Application
Dim oSearch As Outlook.Search
Dim oInbox As Outlook.MAPIFolder
Dim oSearchFolder As Outlook.MAPIFolder
Dim sFolderPath As String
Dim sScope As String
Dim sFilter As String
On Error Resume Next
Set oApp = New Outlook.Application
Set oInbox = oApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
sFolderPath = oInbox.FolderPath
'Build a scope string
sScope = "SCOPE ('shallow traversal of " & Chr$(34) & sFolderPath & Chr$(34) & "')"
'Build a filter string (WHERE clause without the WHERE)
sFilter = Chr$(34) & ("urn:schemas:mailheader:subject") & Chr$(34) & " LIKE 'RE:%'"
'Create the Search object by calling AdvancedFind
Set oSearch = oApp.AdvancedSearch(sScope, sFilter, False, "RE Search")
'Save the Search as a Search Folder
Set oSearchFolder = oSearch.Save("RE Search")
MsgBox oSearchFolder.Items.Count & " Items found!"
'oSearchFolder.Delete
End Sub