How to erase MS OUTLOOK 2003 duplicate mails in my INBOX

  • Thread starter Thread starter Rodryg
  • Start date Start date
R

Rodryg

Hi,

I'd like to erase, from my PC, all duplicate mails of my Inbox. Duplicate
mails are identical mails (same date, origine, sender, ...) that my mail
server (POP) loads more than one time a day because of the option "Keep
mails on server for x... days" is selected. I don't want to change this
setting and I can't use an IMAP server.

So I need a script or a VBA macro to check that point.

Any idea??

Thanks
 
This macro checks for uniqueness before deleting.
It skips over recalls and olReports, other mail classes may also cause it to
bomb, handle those as they are encountered. Assure that your Inbox is sorted
by Received.

Sub deletedupes()
Dim msg As Object
Dim lastEntryID As String
Set myOlApp = CreateObject("Outlook.Application")
Set myNamespace = myOlApp.GetNamespace("MAPI")
Set myFolder = myNamespace.GetDefaultFolder(olFolderInbox)
For Each msg In myFolder.Items
mytext = msg.Subject
If Left(mytext, 6) = "Recall" Then GoTo Done
my1 = msg.Body 'This is for troubleshooting
my2 = msg.EntryID 'This is for troubleshooting
If msg.Class = olReport Then GoTo Done
my3 = msg.SenderName 'This is for troubleshooting
If Left(msg.CreationTime, InStr(15, msg.CreationTime, ":") - 1) =
lastCreationTime Then 'And
If msg.SenderName = lastsender Then
If msg.Body = lastbody Then 'And
If msg.Subject = lastSubject Then
msg.Delete
GoTo Done
End If
End If
End If
End If
lastCreationTime = Left(msg.CreationTime, InStr(15,
msg.CreationTime, ":") - 1)
lastbody = msg.Body
lastSubject = msg.Subject
lastsender = msg.SenderName

Done:
Next msg
End Sub
 
Good job, Dean. Thanks again. This is the right way to eliminate
duplicate emails.

rodryg
 
Back
Top