Freshman
Registered User.
- Local time
- Today, 10:55
- Joined
- May 21, 2010
- Messages
- 437
Hi all,
I'm using the code below to count the number of emails in an Inbox but I want to narrow it down to just the flagged emails.
I'm using the code below to count the number of emails in an Inbox but I want to narrow it down to just the flagged emails.
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("Inbox").Folders("report's").Folders("Customer")
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, , "email count"
End Sub