Avatar of Muhammad Burhan
Muhammad Burhan
Flag for Pakistan

asked on 

Macro for Delete Duplicate Emails in outlook2010

Hey Experts!!
Consider this code as an example, is it possible to create a macro which compare 'subject' of every incoming mail and delete duplicates then and there ?
if its possible so please provide your valuable assistance.
Public Sub ProcessingzabbixEmails(Item As Outlook.MailItem)
    Dim objParent As Outlook.Folder
    Dim objFolder As Outlook.Folder
    Dim objProductionFldr As Outlook.Folder
    Dim strSubject As String
    Dim objProbEmail As Outlook.MailItem
    Set objParent = Outlook.Session.GetDefaultFolder(olFolderInbox).Parent
    Set objProductionFldr = objParent.Folders("Current_Production_Alerts")
    If Right(Item.Subject, 2) = "OK" Then
        Set objFolder = objParent.Folders("Archived_Production_Alerts")
        ' Find Matching Email
        strSubject = Left(Item.Subject, Len(Item.Subject) - 2) & "PROBLEM"
        Set objProbEmail = objProductionFldr.Items.Find("[Subject] = '" & Replace(strSubject, "'", "''") & "'")
        objProbEmail.UnRead = False
        Item.Move objFolder
        objProbEmail.Move objFolder
        Item.UnRead = False
        Item.Move objFolder
        Item.UnRead = True
        Item.Move objProductionFldr
    End If
End Sub

Open in new window

Email ClientsVisual Basic ClassicProgrammingVB Script

Avatar of undefined
Last Comment
Muhammad Burhan

8/22/2022 - Mon