asked on
Public Sub RemoveDuplicates()
If ConfirmDelete = vbYes Then
Dim ns As NameSpace
Dim di As MAPIFolder
Dim mi As Outlook.MailItem
Dim diCount As Integer
Dim miTemp As Outlook.MailItem
Set ns = ThisOutlookSession.Session
Set di = ns.GetDefaultFolder(olFolderDeletedItems)
Set Items = di.ShowItemCount
For i = 1 To Items
miTemp = mi
For Each mi In di
If Not miTemp Then
If miTemp.Subject = mi.Subject And miTemp.SenderEmailAddress = mi.SenderEmailAddress And miTemp.SentOn = mi.SentOn Then
miTemp.Delete
Set Items = Items - 1
End If
End If
Next
Next
Set ns = Nothing
Set di = Nothing
Set mi = Nothing
Set miTemp = Nothing
End If
End Sub
Private Function ConfirmDelete() 'asks before proceeding with delete
Dim warningPrompt As String
Dim warningTitle As String
Dim warningButtons As String
warningPrompt = "Continue with removal of duplicated deleted items?"
warningTitle = "Confirm Delete"
warningButtons = vbYesNo + vbQuestion + vbDefaultButton2
ConfirmDelete = MsgBox(warningPrompt, warningButtons, warningTitle)
End Function
Microsoft Outlook is a personal information manager from Microsoft, available as a part of the Microsoft Office suite. Although often used mainly as an email application, it also includes a calendar, task manager, contact manager, note-taker, journal, and web browser.
TRUSTED BY
ASKER