Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays Outlook中删除重复电子邮件的宏- Public Sub RemDups() 将t作为项目_ i作为整数_ arr作为集合_ f作为文件夹_ 父文件夹_ 目标为文件夹_ miLast作为邮件项目_ mi作为邮件项 设置parent=Application.GetNamespace(“MAPI”).PickFolder Set target=Application.GetNamespace(“MAPI”).PickFolder 对于父文件夹中的每个f 设置t=f项 t、 排序“[主题]” i=1 集miLast=t(i) Set arr=新集合 当我数的时候 i=i+1 如果TypeName(t(i))=“MailItem”,则 设置mi=t(i) 如果miLast.Subject=mi.Subject,miLast.Body=mi.Body_ 然后miLast.ReceivedTime=mi.ReceivedTime A.添加mi 其他的 设置miLast=mi 如果结束 如果结束 温德 对于arr中的每个mi 移动目标 下一个mi 下一个f 端接头_Arrays_Vba_Sorting_Outlook - Fatal编程技术网

Arrays Outlook中删除重复电子邮件的宏- Public Sub RemDups() 将t作为项目_ i作为整数_ arr作为集合_ f作为文件夹_ 父文件夹_ 目标为文件夹_ miLast作为邮件项目_ mi作为邮件项 设置parent=Application.GetNamespace(“MAPI”).PickFolder Set target=Application.GetNamespace(“MAPI”).PickFolder 对于父文件夹中的每个f 设置t=f项 t、 排序“[主题]” i=1 集miLast=t(i) Set arr=新集合 当我数的时候 i=i+1 如果TypeName(t(i))=“MailItem”,则 设置mi=t(i) 如果miLast.Subject=mi.Subject,miLast.Body=mi.Body_ 然后miLast.ReceivedTime=mi.ReceivedTime A.添加mi 其他的 设置miLast=mi 如果结束 如果结束 温德 对于arr中的每个mi 移动目标 下一个mi 下一个f 端接头

Arrays Outlook中删除重复电子邮件的宏- Public Sub RemDups() 将t作为项目_ i作为整数_ arr作为集合_ f作为文件夹_ 父文件夹_ 目标为文件夹_ miLast作为邮件项目_ mi作为邮件项 设置parent=Application.GetNamespace(“MAPI”).PickFolder Set target=Application.GetNamespace(“MAPI”).PickFolder 对于父文件夹中的每个f 设置t=f项 t、 排序“[主题]” i=1 集miLast=t(i) Set arr=新集合 当我数的时候 i=i+1 如果TypeName(t(i))=“MailItem”,则 设置mi=t(i) 如果miLast.Subject=mi.Subject,miLast.Body=mi.Body_ 然后miLast.ReceivedTime=mi.ReceivedTime A.添加mi 其他的 设置miLast=mi 如果结束 如果结束 温德 对于arr中的每个mi 移动目标 下一个mi 下一个f 端接头,arrays,vba,sorting,outlook,Arrays,Vba,Sorting,Outlook,Set miLast=t(i)给出“运行时错误'440'数组索引超出范围” 请提供帮助这是一个在web上创建的修改版本() 这段代码允许选择一个文件夹来搜索和删除重复的项目 Public Sub RemDups() Dim t As Items, _ i As Integer, _ arr As Collection, _ f As Folder, _ parent As Folder, _ target As Folder, _ miLast

Set miLast=t(i)给出“运行时错误'440'数组索引超出范围”
请提供帮助

这是一个在web上创建的修改版本()

这段代码允许选择一个文件夹来搜索和删除重复的项目

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

更好的版本是在递归模式下在其他文件夹中查找重复的电子邮件。

当您得到该错误时,
f.Items.Count
的值是多少?当我编译代码时,我得到的只是“运行时错误”。它不提供任何计数使用t.Item(I)方法通过集合中的索引获取项目。
Option Explicit

'Set a reference to the Microsoft Scripting Runtime from Tools, References.

Sub DeleteDuplicateEmailsInSelectedFolder()

Dim i As Long
Dim n As Long
Dim Message As String
Dim Items As Object
Dim AppOL As Object
Dim NS As Object
Dim Folder As Object

Set Items = CreateObject("Scripting.Dictionary")

'Initialize and instance of Outlook
Set AppOL = CreateObject("Outlook.Application")

'Get the MAPI Name Space
Set NS = AppOL.GetNamespace("MAPI")

'Allow the user to select a folder in Outlook
Set Folder = NS.PickFolder

'Get the count of the number of emails in the folder
n = Folder.Items.Count

'Check each email starting from the last and working backwards to 1
'Loop backwards to ensure that the deleting of the emails does not interfere with subsequent items in the loop
For i = n To 1 Step -1

    On Error Resume Next
    'Load the matching criteria to a variable
    'This is setup to use the Sunject and Body, additional criteria could be added if desired
    Message = Folder.Items(i).Subject & "|" & Folder.Items(i).Body

        'Check a dictionary variable for a match
        If Items.Exists(Message) = True Then
        'If the item has previously been added then delete this duplicate
        Folder.Items(i).Delete
    Else
        'In the item has not been added then add it now so subsequent matches will be deleted
        Items.Add Message, True
End If

Next i

ExitSub:

'Release the object variables from memory
Set Folder = Nothing
Set NS = Nothing
Set AppOL = Nothing

End Sub