Email as of type Outlook.MailItem

G

Guest

Outlook 2003

How to programmatically access e-mails in inbox, any users created folders
inside inbox or sent items as of type outlook.MailItem

Basically, I want to iterate through all the e-mails that are marked with
the yellow flag (in inbox, sent items and any folders created inside the
inbox)
 
M

Michael Bauer [MVP - Outlook]

Am Mon, 7 Aug 2006 09:16:02 -0700 schrieb css:

Sample for the Inbox:

Dim Mail As Outlook.MailItem
Dim Items As Outlook.MAPIFolder
Dim obj as Object

Set Items = Application.Session.GetDefaultFolder(olFolderInbox).Items

For Each obj In Items
If TypeOf obj Is Outlook.MailItem Then
Set Mail=obj
' check for the flag here
End If
Next

For sent items you can also use GetDefaultFolder with the proper constant. A
child folder of the Inbox e.g. would be, assuming you do have the Inbox
already:

Dim Folder as Outlook.Mapifolder
Set Folder = Inbox.Folders("ChildName")
 
C

c_shah

Thanks you. Your approach works wery well.

I apologize I might have posted this multiple times.

One more question, how to process subfolders created within the inbox?
different user's will have folders created within the inbox and they
all can have different names?

Thanks in advance.
 
M

Michael Bauer [MVP - Outlook]

Am 10 Aug 2006 08:57:47 -0700 schrieb c_shah:

You can also loop through the subfolder with:

Dim Folder as Outlook.MapiFolder
For Each Folder in Inbox.Folders
....
Next
 

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