如何删除outlook中的重复邮件

问题背景:

outlook 卸载重装后,会把之前已收的邮件,再次下载到本地,出现大量重复邮件。

解决思路:

搜索outlook邮件删除重复邮件的工具,有outlook duplicate items remover,Duplicate Email Remover,NoMoreDupes for Outlook等。但这些工具都要收费。故换了个思路,用宏来删除。

使用要点:

  • 打开outlook,按快捷键Alt+F11,建立工程,并复制宏。
  • Option Explicit
    
    Sub DeleteDuplicateEmailsInSelectedFolder()
    
    Dim i As Long
    Dim n As Long
    Dim DeletedCount 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
    
    'Set the initial deleted count
    DeletedCount = 0
    
    '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
            DeletedCount = DeletedCount + 1
        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
    
    MsgBox "共删除" & DeletedCount & "封邮件。"
    
    End Sub
  • 然后F5运行此宏即可。
  • 如果提示宏被禁用,主菜单中文件->选项->信任中心,信任中心设置->宏设置,选择“启动所有宏”或者“为所有宏提供通知”。
  • 也可以通过“自定义功能区”把宏显示在主选项卡中。不过不知道为什么,点击它好像没什么反应。好在可以通过F5运行。就不去查原因了。
  •  

 

  • 23
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 16
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值