title: Count Read and Unread Emails date wise for shared mailbox
body: <p>I have edited VBA which I found in Stack Overflow to suit my needs.</p>
  
  <p>It gives me the count of emails of my default inbox date wise and count of unread emails without dates.</p>
  
  <p>I need it to count the emails of my shared mailbox. For example Redstreamattmail and not the default mailbox, DATE WISE for overall emails and unread emails.</p>
  
  <pre><code>Sub HowManyEmails()    
  
  Dim objOutlook As Object, objnSpace As Object, objFolder As MAPIFolder    
  Dim EmailCount As Integer    
  
  Dim a As Outlook.Application    
  Dim b As Outlook.NameSpace    
  Dim c As Outlook.MAPIFolder    
  
  Set a = New Outlook.Application    
  Set b = a.GetNamespace("MAPI")    
  Set c = b.GetDefaultFolder(olFolderInbox)    
  d = c.UnReadItemCount    
  
  Set objOutlook = CreateObject("Outlook.Application")    
  Set objnSpace = objOutlook.GetNamespace("MAPI")    
  
  On Error Resume Next    
  
  Set objFolder = objnSpace.GetDefaultFolder(olFolderInbox)    
  
  If Err.Number &lt;&gt; 0 Then    
      Err.Clear    
      MsgBox "No such folder."    
      Exit Sub    
  End If    
  
  EmailCount = objFolder.Items.Count    
  
  MsgBox "Number of emails in the folder: " &amp; EmailCount &amp; " Total Unread     email count are   " &amp; d    
  
  Dim dateStr As String    
  Dim myItems As Outlook.Items    
  Dim dict As Object    
  Dim msg, msg1 As String    
  
  Set dict = CreateObject("Scripting.Dictionary")    
  Set myItems = objFolder.Items    
  
  myItems.SetColumns ("SentOn")    
  
  ' Determine date of each message:    
  
  For Each myItem In myItems    
      dateStr = GetDate(myItem.SentOn)    
      If Not dict.Exists(dateStr) Then    
          dict(dateStr) = 0    
      End If    
      dict(dateStr) = CLng(dict(dateStr)) + 1    
  Next myItem    
  
  ' Output counts per day:    
  For Each o In dict.Keys    
      msg = msg &amp; o &amp; ":    " &amp; dict(o) &amp; " Email items" &amp; vbCrLf    
  Next    
  msg1 = "unread Emails are        " &amp; d    
  
  Set objFolder = Nothing    
  Set objnSpace = Nothing    
  Set objOutlook = Nothing    
  
  'Send Email    
  Set OutApp = CreateObject("outlook.Application")    
  Set OutMail = OutApp.CreateItem(o)    
  
  With OutMail    
      .Subject = "Count of emails"    
      .To = "name@company.com;"    
      .Body = msg &amp; msg1    
      .Display    
      '.Send    
  End With     
  
  Set OutMail = Nothing    
  Set OutApp = Nothing    
  
  End Sub    
  </code></pre>