title: Scope using AdvancedSearch method for entire mailbox
body: <p>I am trying to look through all Outlook folders for mail items matching certain parameters to save the attachment, from Excel.</p>
  <p>I don't know how to reference scope to go through all folders, even custom folders.</p>
  <p>I can't find the resources that answer my question.</p>
  <pre><code>Sub testing()
  
  Dim myOlApp As New Outlook.Application
  Dim scope As String
  Dim filter As String
  Dim rsts As Results
  Dim AdvancedSearch As Outlook.Search
  
  blnSearchComp = False
  
  'I want it to search the entire mail account including normal folders like inbox and sent as well as custom folders.
  'but this doesn't work. Any ideas?
  scope = &quot;'Fakeexample123@outlook.com'&quot;
  'filter assignment statement has been excluded
  
  Set AdvancedSearch = myOlApp.AdvancedSearch(scope, filter, True, &quot;test&quot;)  
  
  While blnSearchComp &lt;&gt; True
      If AdvancedSearch.Results.Count &gt; 0 Then
          blnSearchComp = True
      End If
  Wend
  
  Set rsts = AdvancedSearch.Results
  
  For x = rsts.Count To 1 Step -1
      rsts.Attachment.Item(x).SaveAsFile Project
  Next
  
  End Sub
  </code></pre>