![如何从辅助邮箱在 Outlook 2007 中创建包含多种对象类型的搜索文件夹?](https://linux22.com/image/1293564/%E5%A6%82%E4%BD%95%E4%BB%8E%E8%BE%85%E5%8A%A9%E9%82%AE%E7%AE%B1%E5%9C%A8%20Outlook%202007%20%E4%B8%AD%E5%88%9B%E5%BB%BA%E5%8C%85%E5%90%AB%E5%A4%9A%E7%A7%8D%E5%AF%B9%E8%B1%A1%E7%B1%BB%E5%9E%8B%E7%9A%84%E6%90%9C%E7%B4%A2%E6%96%87%E4%BB%B6%E5%A4%B9%EF%BC%9F.png)
我向我的帐户添加了一个额外的邮箱。我想创建一个类似于该用户现有的“待办事项列表”视图的视图。这意味着我想要一个搜索文件夹,用于搜索该邮箱中设置了后续标记或属于任务的任何类型的对象。
您无法从 UI 执行此操作。我发现:
Sub CreateNewSearchFolder()
Set MyOutlookApplication = Outlook.Application
SearchSubFolders = True
Set MapiNamespace = Application.GetNamespace("MAPI")
Set TasksFolder = MapiNamespace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderTasks).Parent
strS = "'" & TasksFolder.FolderPath & "'"
'strS = "'\\Mailbox - Other'"
Dim folderName As String
folderName = InputBox("Name of new search folder?:", "Folder Name", "")
Dim objSch As Search
Dim taskFilter As String
taskFilter = "(""http://schemas.microsoft.com/mapi/proptag/0x0e05001f""= 'Tasks' AND ""http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81010003"" <> 2) OR (NOT(""http://schemas.microsoft.com/mapi/proptag/0×10900003"" IS NULL) AND ""http://schemas.microsoft.com/mapi/id/{00062003-0000-0000-C000-000000000046}/81010003"" <> 2)"
Dim strTag As String
strTag = "RecurSearch"
Dim fupFilter As String
fupFilter = "(NOT(""urn:schemas:httpmail:messageflag"" IS NULL))"
Set objSch = Application.AdvancedSearch(Scope:=strS, _
Filter:=taskFilter & " OR " + fupFilter + "", _
SearchSubFolders:=True, Tag:=strTag)
objSch.Save (folderName)
End Sub
这对我的邮箱来说非常完美。也就是说,它创建了一个类似于我想要的待办事项列表视图的视图。它包含每个带有后续标记的对象类型和任务。但是,如果我取消注释该strS = "'\\Mailbox - Other'"
行并运行它,Outlook 会在 .Save() 行上崩溃。
有什么建议吗?