Items Collection Not Sorting Folder - (Outlook 2000 Standalone)

J

Jed_Klampett

I have duplicate messages in a folder called "Dupes" I want to sort by
ReceivedTime, then loop through if subject and received time are the
same. Anyway, sort doesn't work here. Only think I can think of is
maybe there is more than one items collection somehow (got that from
Sue Mosher's posts *thanks*). Any ideas? Thanks. -Noelani Rodriguez

-----------------------
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objInbox = objNameSpace.GetDefaultFolder(olFolderInbox)
Set objFolder = objInbox.Folders("Dupes")

objFolder.Items.Sort "[ReceivedTime]", True

'Read through all items and filter as necessary
For i = 1 To objFolder.Items.Count
Set objMail = objFolder.Items(i)

'Check for duplicates
If objMail.Subject = LastItemName And objMail.ReceivedTime =
LastReceivedTime Then
objMail.Delete
End If

LastItemName = objMail.Subject
MsgBox (LastItemName)
LastReceivedTime = objMail.ReceivedTime
MsgBox (LastReceivedTime)
Next i
 
S

Sue Mosher [MVP-Outlook]

You need an object variable for the Items collection you want sorted:

Set colItems = oibjFolder.Items
colItems.Sort "[ReceivedTime]", True
intCount = colItems.Count
For i = intCount to 1 Step -1
Set objItem = colItems(i)
' do stuff with objItem
Next

Note the use of a countdown loop -- required if you're removing items from
the collection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top