Search notes:

Outlook Object Model: applying filters

A filter is used to search for item objects that match the criteria that are set forth in the filter.

Jet and DASL filters

A filter is formulated either with JET or DASL syntax.
JET DASL
A DASL filter always starts with @SQL=". (In VBA, an apostrophe can be embedded into a string by doubling it: filter = "@SQL=""…""").
Boolean queries [Unread] = true "@SQL=""urn:schemas:httpmail:read"" = 0"
Starts-with queries Not possible "@SQL=""urn:schemas-microsoft-com:office:office#Keywords"" ci_startswith 'Partner'"

Methods that accept filters in their arguments

Outlook's Object Model allows to specify a filter in the following methods:
Method JET Filter Support DASL Filter Support Comment
application.advancedSearch No Yes
folder.getTable Yes Yes
items.find Yes Yes Using query keywords ci_phrasematch or ci_startswith result in errors
items.restrict Yes Yes
search.getTable No Yes
table.findRow Yes Yes Using query keywords ci_phrasematch or ci_startswith result in errors
table.restrict Yes Yes
view.filter No Yes

Search in mail body

option explicit

sub searchInMailBodies(searchText as string) ' {

   dim fld as folder
   set fld = session.getDefaultFolder(olFolderInbox)

   dim DASL_query as string
   DASL_query = "@SQL=""urn:schemas:httpmail:textdescription"" ci_phrasematch '" & searchText & "'"

   dim tbl as table
   set tbl = fld.getTable(DASL_query)

   dim r as row
   do until tbl.endOfTable
      set r = tbl.GetNextRow
      debug.print r("Subject")
   loop

end sub ' }
Github repository about-MS-Office-object-model, path: /Outlook/_filter/search-in-mail-body.vb

See also

Outlook Object Model

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Microsof...', 1737228857, '18.217.57.160', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Outlook/Object-Model/_filter/index(95): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78