Private Sub SearchDeleteObjects(strDomainName As String, strPathOfSourceFolder As String, strRestricSql As String)
Dim Rec As New ADODB.Record
Dim Rst As New ADODB.Recordset
Dim strSourceFolderUrl As String
' set the URL to the location of the folder under which the objects are searched
strSourceFolderUrl = "file://./backofficestorage/" & _
strDomainName & "/" & strPathOfSourceFolder
' open the record
Rec.Open strSourceFolderUrl, , adModeReadWrite 'delete needs parameter adModeReadWrite
' open the recordset - a list of items
Rst.Open strRestricSql, Rec.ActiveConnection
Rst.MoveFirst
Do While Not Rst.EOF
Dim strItemUrl As String
Dim strContentClass As String
' retrieve some propertied
strItemUrl = Rst.Fields("DAV:href")
strContentClass = Rst.Fields("urn:schemas:mailheader:content-class")
'MsgBox Rst.Fields("DAV:displayname")
Rst.Delete 1
' here may make further restriction to the objects to be deleted.
' For example if searched under the Calendar folder
' dim strSubject as string
' dim strLocation as string
' strSubject = Rst.Fields("urn:schemas:httpmail:subject")
' strLocation = Rst.Fields("urn:schemas:calendar:location")
' if strSubject = "Hello" AND strLocation = "LPB-C" then
' Rst.Delete
' End If