0

I am attempting to find all expiring e-mails via Advanced Search method provided below. Optimistically, I hoped that their searches in articles such as this, and this which suggests using 'expires:<=the next month' would do the trick, but it does not.

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

When attmepting to run the above code, I receive the error 'the operation failed'

Here is the reference to the Advanced Search Query provided by Microsoft which has no mention of expiration policy. Does anybody know the Advanced Search Query equivalent to the expires:<=next month feature?

Magnum
  • 1,555
  • 4
  • 18
  • 39

1 Answers1

0

I found it on a reference sheet on MSDN for schemas 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");
Magnum
  • 1,555
  • 4
  • 18
  • 39