0
Public Sub RemDups()
Dim t As Items, _
i As Integer, _
arr As Collection, _
f As Folder, _
parent As Folder, _
target As Folder, _
miLast As MailItem, _
mi As MailItem
Set parent = Application.GetNamespace("MAPI").PickFolder
Set target = Application.GetNamespace("MAPI").PickFolder
For Each f In parent.Folders
Set t = f.Items
t.Sort "[Subject]"
i = 1
Set miLast = t(i)
Set arr = New Collection
While i < t.Count
i = i + 1
If TypeName(t(i)) = "MailItem" Then
Set mi = t(i)
If miLast.Subject = mi.Subject And miLast.Body = mi.Body _
And miLast.ReceivedTime = mi.ReceivedTime Then
arr.Add mi
Else
Set miLast = mi
End If
End If
Wend
For Each mi In arr
mi.Move target
Next mi
Next f
End Sub
設置miLast = T(1)給出了「運行時error'440' 數組索引越界的 請幫宏在Outlook中刪除重複emails-
當你得到這個錯誤時'f.Items.Count'的值是什麼? –
當我編寫代碼時,我得到的只是「運行時錯誤」。它沒有給出任何計數 – sarah
使用** t.Item(i)**方法通過集合中的索引獲取項目。 –