Operating system:: Windows 10
Outlook version: Outlook 2016
Email type or host: Exchage
Outlook version: Outlook 2016
Email type or host: Exchage
Dear all,
I found a great article Batch Delete All Read Receipts that just awesome in removing all read receipts of Outlook folders. I would like to change it a bit so that instead of looping all folders, it would remove read receipts in one folder only. I tried to changed the part from the section "'Process all Outlook files", removed "For Each objStore In Outlook.Application.Session.Stores" and "For Each objFolder In objOutlookFile.Folders" changed to "For Each objFolder In objOutlookFile.Folders", but i do not think I did it correct way (very limited knowledge in VBA of MS outlook). Appreciate if anyone could guide me on correct way how to fix it?
Dim objOutlookFile As Outlook.Folder
Sub BatchDeleteAllReadReceipts()
Dim objStore As Outlook.Store
Dim objFolder As Outlook.Folder
Dim lTotalCount As Long
lTotalCount = 0
'Process all Outlook files
For Each objStore In Outlook.Application.Session.Stores
Set objOutlookFile = objStore.GetRootFolder
For Each objFolder In objOutlookFile.Folders
If objFolder.DefaultItemType = olMailItem Then
Call ProcessFolders(objFolder, lTotalCount)
End If
Next
Next
'Prompt you of the results
MsgBox lTotalCount & " read receipts are deleted!", vbInformation + vbOKOnly
End Sub
Sub ProcessFolders(ByVal objCurrentFolder As Outlook.Folder, lCount As Long)
Dim i As Long
Dim objDeliveryReceipt As Outlook.ReportItem
Dim objSubfolder As Outlook.Folder
Dim objDeletedItems As Outlook.Items
Dim objItem As Object
For i = objCurrentFolder.Items.Count To 1 Step -1
'Find read receipts
If (TypeOf objCurrentFolder.Items(i) Is ReportItem) And (Left(objCurrentFolder.Items(i).Subject, 5) = "Read:") Then
Set objDeliveryReceipt = objCurrentFolder.Items.Item(i)
objDeliveryReceipt.Delete
lCount = lCount + 1
'Permanently delete them
Set objDeletedItems = objOutlookFile.Folders("Deleted Items").Items
For Each objItem In objDeletedItems
If (TypeOf objItem Is ReportItem) And (Left(objItem.Subject, 5) = "Read:") Then
objItem.Delete
End If
Next
End If
Next
'Loop subfolders recursively
If objCurrentFolder.Folders.Count > 0 Then
For Each objSubfolder In objCurrentFolder.Folders
Call ProcessFolders(objSubfolder, lCount)
Next
End If
End Sub
I found a great article Batch Delete All Read Receipts that just awesome in removing all read receipts of Outlook folders. I would like to change it a bit so that instead of looping all folders, it would remove read receipts in one folder only. I tried to changed the part from the section "'Process all Outlook files", removed "For Each objStore In Outlook.Application.Session.Stores" and "For Each objFolder In objOutlookFile.Folders" changed to "For Each objFolder In objOutlookFile.Folders", but i do not think I did it correct way (very limited knowledge in VBA of MS outlook). Appreciate if anyone could guide me on correct way how to fix it?
Dim objOutlookFile As Outlook.Folder
Sub BatchDeleteAllReadReceipts()
Dim objStore As Outlook.Store
Dim objFolder As Outlook.Folder
Dim lTotalCount As Long
lTotalCount = 0
'Process all Outlook files
For Each objStore In Outlook.Application.Session.Stores
Set objOutlookFile = objStore.GetRootFolder
For Each objFolder In objOutlookFile.Folders
If objFolder.DefaultItemType = olMailItem Then
Call ProcessFolders(objFolder, lTotalCount)
End If
Next
Next
'Prompt you of the results
MsgBox lTotalCount & " read receipts are deleted!", vbInformation + vbOKOnly
End Sub
Sub ProcessFolders(ByVal objCurrentFolder As Outlook.Folder, lCount As Long)
Dim i As Long
Dim objDeliveryReceipt As Outlook.ReportItem
Dim objSubfolder As Outlook.Folder
Dim objDeletedItems As Outlook.Items
Dim objItem As Object
For i = objCurrentFolder.Items.Count To 1 Step -1
'Find read receipts
If (TypeOf objCurrentFolder.Items(i) Is ReportItem) And (Left(objCurrentFolder.Items(i).Subject, 5) = "Read:") Then
Set objDeliveryReceipt = objCurrentFolder.Items.Item(i)
objDeliveryReceipt.Delete
lCount = lCount + 1
'Permanently delete them
Set objDeletedItems = objOutlookFile.Folders("Deleted Items").Items
For Each objItem In objDeletedItems
If (TypeOf objItem Is ReportItem) And (Left(objItem.Subject, 5) = "Read:") Then
objItem.Delete
End If
Next
End If
Next
'Loop subfolders recursively
If objCurrentFolder.Folders.Count > 0 Then
For Each objSubfolder In objCurrentFolder.Folders
Call ProcessFolders(objSubfolder, lCount)
Next
End If
End Sub