Try this:
Sub CountMail()
Dim ns As Namespace
Dim mailbox As MAPIFolder
Dim Item As Object
Dim Atmt As Attachment
Dim FileName As String
Dim i As Integer
Set ns = GetNamespace("MAPI")
On Error Resume Next
Set mailbox = ns.Folders("Mailbox - BOB").Folders("Inbox")
If mailbox Is Nothing Then
Worksheets("Sheet1").Cells(3, 2) = "N/A"
Else
Worksheets("Sheet1").Cells(3, 2) = mailbox.Items.Count
End If
Set mailbox = Nothing
Set mailbox = ns.Folders("Mailbox - JOHN").Folders("Inbox")
If mailbox Is Nothing Then
Worksheets("Sheet1").Cells(4, 2) = "N/A"
Else
Worksheets("Sheet1").Cells(4, 2) = mailbox.Items.Count
End If
End Sub
Bookmarks