How to loop through items in an Exchange Mailbox?

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.
 
S

Sue Mosher [MVP-Outlook]

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top