
How to delete selective items from Sent Items from PF Script
I have a PF script from which I need to delete selective items from
the Sent Items folder. The following bit of code shows how I use a
filter to identify the messages I want from custom properties.
Set SntMsgs = myFolder.messages
SntMsgs.Filter=Nothing
Set oMsgFilter = SntMsgs.Filter
oMsgFilter.Fields.Add "EmployeeName", 8, StaffName
oMsgFilter.Fields.Add "StartDate", 7, dtStart
iMsgCount = SntMsgs.count
Call DebugAppend("Number of Items in Sent Items To "& StaffName & "
and StartDate of " &dtStart &" =" & SntMsgs.count,False)
If iMsgCount > 0 Then
For i = 1 to iMsgCount
Call DebugAppend("Deleting Item" & i,False)
SntMsgs.Item(1).Delete 1
Next
Else
Call DebugAppend("No Item Found",False)
End If
The DebugAppend statements write output to the log file and show that
I have a subset of the messages. However despite being in a loop the
Delete line only deletes the first item. If there are more than 1 item
matching the others are left.
Can anyone point out where I am going wrong. The requirement is to
delete all items that match the filter criteria.
Thanks,
Ross Ellard
Devonport Management Limited