Hopefully this can be done... From access, I need to count the number of emails in an Outlook mailbox that is on the Outlook Server but not attached to my Outlook. The code below only works if it's attached as a mailbox to my outlook. We're currently running Office 2010 32 bit and Outlook Server 2003. In the near future, the Outlook Server will be upgraded to 2010.

Here's the code that DOES work if the mailbox is attached to my Outlook. What would I need to change if the mailbox is NOT attached???

ANY help will be greatly appreciated! THANKS!
Cindy

'****Counts the number of emails in Outlook's inbox
Function HowManyEmails() As Integer

Dim objOutlook As Object, objnSpace As Object
Dim objFolder As Object

'Create an application instance with server name
Set objOutlook = CreateObject("Outlook.Application")
Set objnSpace = objOutlook.GetNamespace("MAPI")

HowManyEmails = 0

On Error Resume Next
Set objFolder = objnSpace.Folders("Intake").Folders("Inbox")

' Get the StoreID, which is a property of the folder.
StoreID = objFolder.StoreID



If Err.Number <> 0 Then
Err.Clear
Exit Function
End If


HowManyEmails = objFolder.Items.Count
Set objFolder = Nothing
Set objnSpace = Nothing
Set objOutlook = Nothing

End Function