title: How to filter an Outlook view in VBA based on "To" email addresses
body: <p>I have a view in Outlook that includes both "From" and "To" emails from a mailbox</p>
  
  <p>I can very easily type in an email address into the Outlook search box, and the view will be instantly filtered to show all emails to and from the email address (plus perhaps, any other emails including this email address in the subject or body, but that's not an issue)</p>
  
  <p>I would like to replicate this process via VBA - I have an Access DB with contact details, and would like to be able to simply filter this view based on a contact email address in the DB.</p>
  
  <p>It seems like a very simple problem, but I can't find the solution. I have code that eg filters based on the from email address, but there seems no way to filter on a 'To' email address (I can filter on the 'To' display name but this is next to useless - it varies from one email to another, and seldom if ever contains the actual email address)</p>
  
  <p>I have a DASL filter code that works to filter on the 'From' email addresses using DASL syntax as follows:</p>
  
  <pre><code>Const SchemaFrom As String = "urn:schemas:httpmail:fromemail"
  Dim EM as string
  EM = "myemail@me.com"
  objView.Filter = Chr(34) &amp; SchemaFrom &amp; Chr(34) &amp; " = '" &amp; EM &amp; "'"
  </code></pre>
  
  <p>But there is nothing similar for 'To' emails.</p>
  
  <p>Ultimately I don't even need to filter based on eg the 'From' and 'To' email addresses - if there is a way to code this, so, like in the search box, it simply filters on any text field containing the email address that would be fine by me!!!</p>
  
  <p>For example, is there a generic DASL search that will do this, so no need to eg dictate searching in eg fromemail?</p>
  
  <p>All help much appreciated - it is so simple to do in the GUI of Outlook it must be possible from VBA surely?!</p>