我向我的帐户添加了一个额外的邮箱。我想创建一个类似于该用户现有的“待办事项列表”视图的视图。这意味着我想要一个搜索文件夹,用于搜索该邮箱中设置了后续标记或属于任务的任何类型的对象。
您无法从 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() 行上崩溃。
有什么建议吗?