2
I added an additional mailbox to my account. I want to create a view that is similar to the 'to do list' view that exists for that user. This means I want a search folder that searches that mailbox for objects of any type that have a follow up flag set or is a task.
You cannot do this from the UI. I found this:
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
This works perfectly - for my mailbox. That is, it creates a view similar to the to-do list view that I want. It has every object type with a follow up flag, and tasks. However, if i uncomment the strS = "'\\Mailbox - Other'"
line and run it, Outlook crashes on the .Save() line.
Any advice?
When Outlook cranes on the other Mailbox, is there any error message shown, or any more info that you could give us, about exactly what happens? – Clare Macrae – 2011-10-26T06:16:28.377
It crashes with an Access Violation (c0000005) at 0x000479ff while executing the .Save() line. – EB. – 2011-10-26T17:05:24.687