2013-04-19 346 views
1

我正在編程式地創建一個新的資源管理器窗口來查找1年或更長的所有項目。如何使用Outlook的高級查找找到所有1年或1年以上的郵件?

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(); 

上面的代碼不起作用,因爲搜索不承認urn:schemas:httpmail:datereceived < '4/18/2013 10:48:11 PM'作爲一個有效的搜索。但是,它確實將「收到:今年」或「收到:去年」作爲搜索結果。

enter image description here

我需要使用獲得接收到的所有物品一年前或更什麼字符串?

回答