搜索类别

时间:2014-03-14 13:55:20

标签: outlook-vba

我想在所有Outlook文件夹中搜索特定类别的电子邮件,如果找到则将其移至“已关闭”文件夹。

1 个答案:

答案 0 :(得分:0)

需要相当多的代码。首先要通过alle文件夹,你需要这样的东西:

Sub run_alle_folders()
   Dim Ol, Mf, Mf1, mf2, Ns, mf3, mf4, mf5, mf6, i&
   On Error Resume Next
   Set Ol = CreateObject("Outlook.Application")
   Set Ns = Ol.GetNamespace("MAPI")
   For Each Mf In Ns.Folders
      for each item in Mf
          check_for_categorie_and_move(item) 'this should call your code
          next
        For Each Mf1 In Mf.Folders
            for each item in Mf1
                check_for_categorie_and_move(item) 'this should call your code
                next
          For Each mf2 In Mf1.Folders
               for each item in Mf2
                   check_for_categorie_and_move(item) 'this should call your code
                   next
            For Each mf3 In mf2.Folders
                 for each item in Mf3
                     check_for_categorie_and_move(item) 'this should call your code
                     next
               For Each mf4 In mf3.Folders
                   for each item in Mf4
                       check_for_categorie_and_move(item) 'this should call your code
                       next
  Next
   Set Ns = Nothing: Set Mf1 = Nothing: Set Mf = Nothing: Set Ol = Nothing: Set Tb = Nothing
   Set mf2 = Nothing: Set mf3 = Nothing: Set mf4 = Nothing: Set mf5 = Nothing: Set mf6 = Nothing
End Sub

为了检查类别和移动项目(我将它放入一个单独的Sub)你应该很容易找到足够的代码。

最高

相关问题