Search notes:

Outlook Object Model: Application.AdvancedSearch

option explicit

sub main() ' {

    dim scope as string
        scope = "'" & session.getDefaultFolder(olFolderInbox   ).folderPath & "'," & _
                "'" & session.getDefaultFolder(olFolderSentMail).folderPath & "'"

    dim query as string
        query = "urn:schemas:mailheader:subject = 'XYZ'"

    advancedSearch scope, query, searchSubFolders := false, tag := "tq84"

end sub ' }
Github repository about-MS-Office-object-model, path: /Outlook/Application/advancedSearch/main.vb
option explicit

private sub application_advancedSearchComplete(byVal found as search) ' {
  '
  ' Put this event into 'ThisOutlookSession' module
  '
    debug.print "search with tag " & found.tag & " completed"

  '
  ' dim tab as table
  ' set tab = found.getTable

    dim email as mailItem
    for each email in found.results
         email.display
    next email

end sub ' }
Github repository about-MS-Office-object-model, path: /Outlook/Application/advancedSearch/advancedSearchComplete.vb

See also

When the advancedSearch() method complets, the application.advancedSearchComplete event is triggered.
Outlook Object Model: applying filters

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...', 1759408129, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Microsoft/Office/Outlook/Object-Model/Application/advancedSearch/index(76): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78