【问题标题】:How to search by choosing a category from the category dialog?如何通过从类别对话框中选择类别进行搜索?
【发布时间】:2021-04-03 00:44:17
【问题描述】:

我想在 Outlook 搜索栏上搜索关键字。理想的过程是我可以使用搜索工具热键添加属性(例如Sent ToReceivercc等)。

我直观地认为属性或关键字将存在于特定邮件项目上。当我搜索 Sent ToReceivercc 时它可以工作,但是当我想通过以下方式搜索特定类别时它会出现一些问题“类别”。它不会显示完整的类别列表。这里有相关评论。

有图供实际操作参考。

由于我有很多类别来管理我的电子邮件,我希望通过完整类别对话框选择一个类别,并将其输入到 Outlook 搜索栏。这样我就可以更快更准确地找到我想要的邮件了。

VBA代码有我的初步想法。 (Credit to MarcinSzaleniec):

Sub SearchByInputFromCategoryDialog
  'Open Category Dialog and choose one category
  StringOfCategory = Choosing Text
 
  txtSearch = "category:="category:(StringOfCategory )"
  myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
end Sub

然后类别文本将显示在搜索栏上,以便我可以进一步击键“输入”并开始搜索过程。

备注:

类别对话框可能存在问题,因为我无法找到是否存在通过类别对话框获取类别文本的 VBA 方法。

我在 Internet mainly focus on an item or selected item on explorer to add the category by the category dialog 上找到的信息最多,但是我想使用的方法是通过类别对话框获取类别文本

【问题讨论】:

    标签: vba outlook outlook-2016


    【解决方案1】:

    您可以从支持类别的对象返回类别。

    Option Explicit ' Consider this mandatory
    ' Tools | Options | Editor tab
    ' Require Variable Declaration
    ' If desperate declare as Variant
    
    Sub SearchByInputFromCategoryDialog()
    
        Dim StringOfCategory As String
        Dim txtSearch As String
        
        Dim obj As Object
            
        'Open Category Dialog and choose one category
        Set obj = CreateItem(olMailItem)
        obj.ShowCategoriesDialog
        StringOfCategory = obj.categories
        Debug.Print StringOfCategory
        
        'txtSearch = "category:=""Red category"""
        'Debug.Print txtSearch
        
        txtSearch = "category:=""" & StringOfCategory & """"
        Debug.Print txtSearch
         
        ActiveExplorer.Search txtSearch, olSearchScopeAllFolders
    
    End Sub
    

    【讨论】:

    • 非常感谢您的回复,功能完全符合我的要求。感谢您的大力帮助〜
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多