count unread messages -> exchange server mailbox

how can i count the unread messages in a exchange server's mailbox
hubert1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Neo_mvpsCommented:
For just the Inbox or all folders of a mailbox?
0
snoop_doggy_doggCommented:
Can't you just grap the MAPIFolder object you're querying and grab the UnReadItemCount value?

Woof!
http://www.woofwoofwoof.com
0
hubert1Author Commented:
hi neo,

just for ONE mailbox (exchange server)
0
Neo_mvpsCommented:
The following will work if you want to use the Outlook Object Model and VB. (Information was taken from http://support.microsoft.com/support/kb/articles/q171/6/03.asp )

Option Explicit

   Private Sub Main()
      Dim olMAPI As Outlook.NameSpace
      Dim Folder As Outlook.MAPIFolder
      Const FOLDER_TO_OPEN = "Mailbox - John Doe"   'Modify as appropriate

      Set olMAPI = GetObject("", "Outlook.Application") _
                              .GetNamespace("MAPI")
      Call PrintFolderNames(olMAPI.Folders(FOLDER_TO_OPEN), "->")
      Set olMAPI = Nothing
   End Sub

   Sub PrintFolderNames(tempfolder As Outlook.MAPIFolder, a$)
      Dim i As Integer
      If tempfolder.Folders.Count Then
         Debug.Print a$ & " " & tempfolder.Name & "  ";
         Debug.Print tempfolder.UnReadItemCount
         For i = 1 To tempfolder.Folders.Count
           Call PrintFolderNames(tempfolder.Folders(i), a$ & "->")
         Next i
      Else
         Debug.Print a$ & " " & tempfolder.Name & "  ";
         Debug.Print tempfolder.UnReadItemCount
      End If
   End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Outlook

From novice to tech pro — start learning today.