如何使用Outlook高级搜索通过分配的服务器策略查找过期的电子邮件

时间:2013-04-26 06:10:32

标签: c# outlook vsto outlook-2010

我试图通过下面提供的高级搜索方法查找所有即将到期的电子邮件。乐观地说,我希望他们的搜索in articles such as thisthis建议使用'过期:< =下个月'就行了,但事实并非如此。

string filter = String.Format("expires:<=next month");
string scope = "'" + inboxFolder.FolderPath + "'";
Outlook.Search search = Globals.ThisAddIn.Application.AdvancedSearch(scope, filter, true, "Expiring Retention Policy Mail");

当attmepting运行上面的代码时,我收到错误'操作失败'

这是reference Microsoft提供的高级搜索查询,未提及过期策略。 是否有人知道相当于过期的高级搜索查询:&lt; =下个月的功能?

1 个答案:

答案 0 :(得分:0)

我在MSDN上的参考表上找到了模式here

DateTime expirationDate = DateTime.Now.AddDays(30);
string expiresFilter = String.Format("urn:schemas:mailheader:expires>'{0}' AND urn:schemas:mailheader:expires<'{0}'", DateTime.Now, expirationDate);
string scope = "'" + inboxFolder.FolderPath + "'";
Outlook.Search search = Globals.ThisAddIn.Application.AdvancedSearch(scope, expiresFilter, true, "Expiring Retention Policy Mail");
相关问题