Platform SDK: Exchange 2000 Server |
[This is preliminary documentation and subject to change.]
To delete all items in a folder, you can use a Recordset object’s Delete method. The following example deletes all the items in a folder, except for any subfolders as stipulated by a WHERE clause.
Dim Rec Dim Rs Dim strURL Dim strQ Dim DomainName Dim strLocalPath 'specify own domain for DomainName variable DomainName = "microsoft.com" 'specify URL to a folder for the strLocalPath variable strLocalPath = "public folders/oldstuff" Set Rec = CreateObject("ADODB.Record") Set Rs = CreateObject("ADODB.Recordset") 'this URL is for a public folder strURL = "file://./backofficestorage/" & DomainName & "/" & strLocalPath 'Open a Record object for use with the Recordset Rec.Open strURL 'Create a query with a WHERE clause to keep subfolders strQ = "SELECT * FROM scope('shallow traversal of " & Chr(34) & strURL & Chr(34) & "')" strQ = strQ & " WHERE ""DAV:isfolder"" = FALSE" 'Open the recordset Rs.Open strQ, Rec.ActiveConnection Rs.MoveFirst Do Until Rs.EOF 'you could perform confirmations here on the current 'record's values to abort deletion using an if statement 'Delete current record (row), 1 is parameter for current record Rs.Delete 1 Rs.MoveNext Loop Rs.Close Rec.Close