0

I'm trying to convert the following working powershell OOM items.restrict:

$colMail = $olFolder.Items.Restrict("[Start] > '18/03/2022'")
$colMail = $olFolder.Items.Restrict("[Subject] = 'Test'")

RDO items.restrict

$SQL = "Subject = 'Test'" # or "where Subject = 'Test'"
$colMail = $olFolder.Items.Restrict($SQL)
$colMail = $olFolder.Items.Restrict("Subject = 'Test'")
$colMail = $olFolder.Items.Restrict("where Subject = 'Test'")
$colMail = $olFolder.Items.Restrict("Start > '2022-03-18'")

Neither of the RDO examples does return any items. Also items.find isnt't working with RDO.

What is the correct SQL-statement in Powershell?

Thanks

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
Mario
  • 1
  • 1

1 Answers1

0

Here is what the documentation says:

SQL style query specifying the condition. Can either be a WHERE part only (e.g. "LastName = 'Streblechenko' ") or a complete SQL expression with the SELECT, WHERE and ORDER BY clauses (see example).

The properties specified in the SQL query must either use the Outlook Object Model (or RDO) property name (e.g. Subject, Email1Address) or a DASL style property name (e.g. "http://schemas.microsoft.com/mapi/proptag/0x0037001E", "http://schemas.microsoft.com/mapi/id/{00062004-0000-0000-C000-000000000046}/8083001E")

When a DASL property name is used, it must be enclosed in double quotes.

Including the SELECT clause allows Redemption to pre-fetch the properties from the folder contents table without opening the item resulting in a significant performance gain (see example). If you later access a property not specified in the SELECT clause, Redemption will open the item.

Including the ORDER BY clause sorts the collection in the specified order.

For example:

set Contact = Items.Restrict("SELECT Email1Address, FileAs from Folder WHERE LastName = 'PersonLastName' ORDER BY FirstName desc")
Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45