Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing Duplicate Emails in PST file

Status
Not open for further replies.

Gavona

Technical User
Aug 27, 2002
1,771
GB
From time to time my Outlook PST files get out of synchronisation (between desktop/network and laptop)- so I end up with two PST files. I import the contents of one into the other selecting "do not import duplicates" then delete one of the pst files.
I reckon that I must have ommitted to use the "do not import duplicates" option once or twice as I have a large number of duplicates.
Can anyone help me develop some code to delete duplicates please?
I would define a duplicate as having:
same date/time sent,
same title
same date/time recieved
same recipient
same sent by

If Outlook records date/time modified then I would want to retain the most recent.
 
Anyone, please!

Gavona

Good luck.
Gavona
 
I would use MS Access as your starting point. Create a table with those fields you list plus one to hold the index of the message in the folder. Write a query to determine which messages to delete based on your criteria - sort it descending by message index.

Open a recordset based on the table and then open the Outlook folder from Access. Read those fields from each message and load the table (Add method on the recordset).

Then open the query as a recordset. Use the Delete method on the messages using the message index. The query needs to be sorted descending by message index because the higher number indexes will change as you delete messages. You also should make sure you don't receive any new messages while running this process.

You might want to do this in two steps so you can review the query results first and make sure you are deleting the correct messages.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top