title: Searching for phone numbers in email subject line
body: <p>Starting with the example at <a href="http://msdn.microsoft.com/en-us/library/office/aa209973(v=office.11).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/office/aa209973(v=office.11).aspx</a>, I was able to create the following block of code that searches the Outlook inbox for emails where the subject line starts with a specific phone number '555-5555' using "ci_startswith".  </p>
  
  <pre><code>Public blnSearchComp As Boolean
  
  Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As Search)
      MsgBox "The AdvancedSearchComplete Event fired."
      blnSearchComp = True
  End Sub
  
  Sub TestAdvancedSearchComplete()
      Dim sch As Outlook.Search
      Dim rsts As Outlook.Results
      Dim i As Integer
      blnSearchComp = False
      Const strF As String = "urn:schemas:mailheader:subject ci_startswith '555-5555'"
      Const strS As String = "Inbox"   
      Set sch = Application.AdvancedSearch(strS, strF) 
      While blnSearchComp = False
          DoEvents
      Wend 
      Set rsts = sch.Results
      For i = 1 To rsts.Count
          MsgBox rsts.Item(i).SenderName
      Next
  End Sub
  </code></pre>
  
  <p>Obviously, if the subject line does not start with the exact phone number, in this case '555-5555', the search doesn't find the email.  In place of "ci_startswith", I tried using the "like" comparison, however this now fails to find any matches, including those found with the "ci_startswith".</p>
  
  <pre><code>    Const strF As String = "urn:schemas:mailheader:subject like '555-5555'"
  </code></pre>
  
  <p>Am I using the "like" comparison incorrectly?  From what I've read, it appears it should work.  Or is this a known bug/issue?  If so, are there any workarounds that provide a broader search ability?</p>
  
  <p>Ultimately, I'd like to use something like below to be able to search for all possible instances of a phone number.</p>
  
  <pre><code>    Const strF As String = "urn:schemas:mailheader:subject like '###-####'"
  </code></pre>
  
  <p>Thanks in advance!</p>
  
  <p>--------- EDIT / ADD ---------</p>
  
  <pre><code>Public blnSearchComp As Boolean
  
  Private Sub Application_AdvancedSearchComplete(ByVal SearchObject As search)
      MsgBox "The AdvancedSearchComplete Event fired."
      blnSearchComp = True
  End Sub
  
  Sub TestAdvancedSearchComplete()
      Dim sch As Outlook.search
      Dim rsts As Outlook.Results
      Dim i As Integer
      blnSearchComp = False
      Const strF As String = "urn:schemas:mailheader:subject LIKE '%###%'"
      Const strS As String = "Inbox"
      Set sch = Application.AdvancedSearch(strS, strF)
      While blnSearchComp = False
          DoEvents
      Wend
      Set rsts = sch.Results
      For i = 1 To rsts.Count
          MsgBox rsts.Item(i).SenderName
      Next
  End Sub
  </code></pre>