I am programmatically creating a new explorer window to find all items that are 1 year or older.
Outlook.Folder folder = (Outlook.Folder)Globals.ThisAddIn.Application.Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Explorer newExplorer = Globals.ThisAddIn.Application.Explorers.Add(folder, Microsoft.Office.Interop.Outlook.OlFolderDisplayMode.olFolderDisplayNoNavigation);
DateTime expirationDate = DateTime.Now;
string searchSyntax = String.Format("urn:schemas:httpmail:datereceived < '{0}'", expirationDate);
newExplorer.Search(searchSyntax, Outlook.OlSearchScope.olSearchScopeAllFolders);
newExplorer.Display();
The above code doesn't work because the search doesn't recognize urn:schemas:httpmail:datereceived < '4/18/2013 10:48:11 PM'
as a valid search. However, it does recognize "received:this year" or "received:last year" as a search result.
What string would I need to use to get all items received one year ago or more?
http://msdn.microsoft.com/en-us/library/office/cc513841(v=office.12).aspx
<
received:<11/1/06 Finds items received before 11/1/06.
received:<4/18/13