zabiullakhan
Active Member
- Joined
- Aug 30, 2010
- Messages
- 310
Macro Count emails in your outlook inbox
Please help me step by step as am not able to get the count with the code below. i guess am missing some config on objOutlook.GetNamespace("MAPI") and from which folder do i get the count
Please help
Please help me step by step as am not able to get the count with the code below. i guess am missing some config on objOutlook.GetNamespace("MAPI") and from which folder do i get the count
Code:
Sub HowManyEmails()
Dim objOutlook As Object, objnSpace As Object, objFolder As Object
Dim EmailCount As Integer
Set objOutlook = CreateObject("Outlook.Application")
Set objnSpace = objOutlook.GetNamespace("MAPI")
On Error Resume Next
Set objFolder = objnSpace.Folders("Personal Folders").Folders("MIS")
If Err.Number <> 0 Then
Err.Clear
MsgBox "No such folder."
Exit Sub
End If
EmailCount = objFolder.Items.Count
Set objFolder = Nothing
Set objnSpace = Nothing
Set objOutlook = Nothing
MsgBox "Number of emails in the folder: " & EmailCount, , "MIS email count"
End Sub
Please help