Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Restrict
Dim myOutlook As Outlook.Application
Dim ns As Outlook.NameSpace
Dim fld As Outlook.MAPIFolder
Dim itms As Outlook.Items
Dim itm As Object
Dim firstMail As MailItem
Dim duplicates As Collection
Set olOutlook = CreateObject("Outlook.Application")
Dim firstSender As String
Dim firstDate As Date
Dim firstSubject As String
Dim firstSize As Long
Dim toField As String
Dim ccField As String
Set ns = olOutlook.GetNamespace("MAPI")
'Let me select which folder to process
Set itms = ns.PickFolder().Items
On Error GoTo errorHandler
For Each firstMail In itms
firstSender = firstMail.SenderName
firstDate = firstMail.ReceivedTime
toField = firstMail.To
ccField = firstMail.CC
firstSubject = firstMail.Subject
firstSize = firstMail.Size
Dim query As String
Set duplicates = itms.Restrict(query)
For Each eachDuplicate In duplicates
eachDuplicate.Delete
MsgBox "Delete duplicate mail From '" + firstSender + "' size-" + firstSize _
+ " with subject '" + firstSubject + "'"
Next
Exit For
Next
errorHandler:
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext
query = "[SenderName]=" & Chr(39) & firstSender & Chr(39) & " And [Subject]=" & _
Chr(39) & firstSubject & Chr(39) & " And [Size]=" & firstSize
Set firstDuplicate = itms.Find(query)
query = "[SenderName]=" & Chr(39) & firstSender & Chr(39) & " And [Subject]=" & _
Chr(39) & firstSubject & Chr(39) & " And [Size]=" & firstSize
Set duplicateCollections = itms.Restrict(query)