title: How to set Outlook sub-folders of a shared default folder?
body: <p>I am trying to extract information from sub-folders of a shared Outlook inbox.</p>
  <p>When I set the folder to the shared inbox (olFolderInbox) the code works perfectly, however, when I set it to a sub-folder, the code will sometimes fail. I ensured that the sub-folder name was correct.</p>
  <p>Here is my code:</p>
  <pre><code>Dim OutlookNameSpace As Outlook.Namespace
  Dim OutlookFolder As Outlook.Folder
  Dim OutlookMail As Outlook.MailItem
  Dim ObjOwner As Outlook.Recipient
  
  Set OutlookNameSpace = Outlook.Application.GetNamespace(&quot;MAPI&quot;)
  Set ObjOwner = OutlookNameSpace.CreateRecipient(&quot;EmailName@email.ca&quot;)
  ObjOwner.Resolve
  
  If ObjOwner.Resolved Then
  
    Set OutlookFolder = OutlookNameSpace.GetSharedDefaultFolder _ 
      (ObjOwner, olFolderInbox).Folders(&quot;FolderName&quot;)
  
  End If
  </code></pre>
  <p>The error message is:</p>
  <blockquote>
  <p>&quot;Run-time error '-2147221233 (8004010f)':<br />
  The attempted operation failed. An object could not be found.&quot;</p>
  </blockquote>
  <p>The debugging tool highlights the line where I tried to set the sub-folder as the Outlook Folder.</p>
  <p>When I comment out: <code>.Folders(&quot;FolderName&quot;)</code> the macro runs fine.</p>
  <p>Why does this code sometimes fail?</p>