title: Vba import emails from shared mailbox on Outlook to excel
body: <p>Can you please help me with this code? I need to know the total emails received by the shared mailbox. My code works smoothly but only shows the count of unread emails on inbox. I want it to show read and unread both.</p>
  
  <p>Please see below for code:</p>
  
  <pre><code>Sub getDataFromOutlook()
  Dim OutlookApp As Outlook.Application
  Dim OutlookNamespace As Namespace
  Dim Folder As MAPIFolder
  Dim OutlookMail As Variant
  Dim objOwner As Outlook.Recipient
  Dim i As Integer
  
  Set OutlookApp = New Outlook.Application
  Set OutlookNamespace =    OutlookApp.GetNamespace("MAPI")
  Set objOwner =  OutlookNamespace.CreateRecipient("xxxxxx@xxxxxx.com")
  objOwner.Resolve
  
  If objOwner.Resolved Then
      Set Folder =     OutlookNamespace.GetSharedDefaultFolder(objOwner, olFolderInbox)
  End If
  
  i = 1
  
  For Each OutlookMail In Folder.Items
  
      If OutlookMail.ReceivedTime &gt;= Range("email_ReceiptDate").Value Then
  
          Range("email_Subject").Offset(i, 0) = OutlookMail.Subject
          Range("email_Subject").Offset(i, 0).Columns.AutoFit
          Range("email_Subject").Offset(i, 0).VerticalAlignment = xlTop
          Range("email_Date").Offset(i, 0) = OutlookMail.ReceivedTime
          Range("email_Date").Offset(i, 0).Columns.AutoFit
          Range("email_Date").Offset(i, 0).VerticalAlignment = xlTop
          Range("email_Sender").Offset(i, 0) = OutlookMail.SenderName
          Range("email_Sender").Offset(i, 0).Columns.AutoFit
          Range("email_Sender").Offset(i, 0).VerticalAlignment = xlTop
          Range("email_Body").Offset(i, 0) = OutlookMail.Body
          Range("email_Body").Offset(i, 0).Columns.AutoFit
          Range("email_Body").Offset(i, 0).VerticalAlignment = xlTop
  
          i = i + 1
  
      End If
  
   Next OutlookMail
  
   Set Folder = Nothing
   Set OutlookNamespace = Nothing
   Set OutlookApp = Nothing
  
  End Sub
  </code></pre>