How to loop through items in an Exchange Mailbox?

  • Thread starter Thread starter deko
  • Start date Start date
D

deko

I've written a good bit of VBA and have automated Outlook on my home PC, but I'm
now tasked with automating an Exchange Mailbox for a small company.

Users have two Exchange Mailboxes visible in their folder list - an Inbox for
their own mail, and an Inbox for a shared alias. What I need to do is loop
through items in the shared Inbox, inspect message date/time, and do stuff based
on what is found.

Code that I understand looks something like this:

Dim olapp As Outlook.Application
Dim olns As Outlook.NameSpace
Dim obj As Object

Set olapp as New Outlook.Application
Set olns = olapp.GetNamespace("MAPI")
Set olFolder = olns.GetDefaultFolder(olFolderInbox)
. . .
. . .

For Each objItem in olFolder

[inspect email message for desired criteria, do stuff if match]

Next

Any suggestion on getting started? How to I instantiate the Exchange Mailbox I
need? Do I have to use CDO?

Thanks in advance.
 
To access the Inbox in the other mailbox, you simply use GetSharedDefaultFolder rather than GetSharedFolder. Complete details and code example in Help.
 
Back
Top