Hey Guys
I have the following code which counts items in a mailbox:
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")
Set mailbox = ns.Folders("Mailbox - BOB").Folders("Inbox")
EmailItemCount = mailbox.Items.Count
Worksheets("Sheet1").Cells(3, 2) = EmailItemCount
Set mailbox = ns.Folders("Mailbox - JOHN").Folders("Inbox")
EmailItemCount = mailbox.Items.Count
Worksheets("Sheet1").Cells(4, 2) = EmailItemCount
End Sub
I want to be able to run a check to see if the mailbox exists before I do an email count.
So I need an IF statement to check if mailbox exists in destination, if yes then run email count and put in Cells(x,y) else if mailbox doesnt exist then put "N\A" in Cells(x,y).
Bookmarks