count unread messages -> exchange server mailbox

how can i count the unread messages in a exchange server's mailbox
hubert1Asked:
Who is Participating?
 
Neo_mvpsConnect With a Mentor Commented:
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
 
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
All Courses

From novice to tech pro — start learning today.