【问题标题】:Delete items in Outlook by 'Type' or 'Message Class'按“类型”或“邮件类别”删除 Outlook 中的项目
【发布时间】:2020-05-14 09:02:13
【问题描述】:

我想删除会议通知。

电子邮件未按“类型”或“消息类别”排序。

Dim olSearchOlFolder As Outlook.MAPIFolder
Dim mailItem As Object

Set mailItem = olSearchOlFolder.items
olSearchOlFolder.items.Sort "[Message Class]", True

For Each mailItem In olSearchOlFolder.items

    Select Case olSearchOlFolder.Name
    Case "Inbox", "Sent Items"
        Select Case olItemMeetingResponse.Class
        Case olMeetingResponsePositive, olMeetingResponseNegative
            olItemMeetingResponse.Delete
        End Select
    End select

next mailItem

【问题讨论】:

    标签: vba outlook


    【解决方案1】:

    不要遍历文件夹中的所有项目,让商店提供商完成这项工作 - 调用 Items.Restrict 并查询 MessageClass 属性

    set restrictedItems = olSearchOlFolder.items.Restrict(" @SQL=""http://schemas.microsoft.com/mapi/proptag/0x001A001F"" LIKE 'IPM.Schedule.Meeting.%' ")
    

    【讨论】:

    • Streblechenko,谢谢你,帮助很大。我首先尝试了您的建议,我得到错误列表分隔符或),在我进行更改后我得到了错误条件无效:Set restrictedItems = olSearchOlFolder.Items.Restrict(" @SQL=" & "https://schemas.microsoft.com/mapi/proptag/0x001A001F" & "like '%IPM.Schedule.Meeting.%' ")
    • 我也收到了"Cannot parse condition error at https://schemas.microsoft.com/mapi/proptag...
    • DASL 名称需要被引用 - 请参阅上面的更新答案。
    • 引用并抛出`condition is not valid
    猜你喜欢
    • 1970-01-01
    • 2014-08-11
    • 2016-10-20
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 2018-10-22
    • 1970-01-01
    • 2021-11-28
    相关资源
    最近更新 更多