Accessing Email Messages - Outlook Automation

The following VB6 code demonstrates how to access email messages via Outlook Automation.

Dim app As Outlook.Application
Dim ns As Outlook.Namespace
Dim f As Outlook.Folder
Dim i As Integer
Dim imax As Integer
Dim msg As Outlook.MailItem

Set app = New Outlook.Application
Set ns = app.GetNamespace("MAPI")
Set f = ns.GetDefaultFolder(olFolderInbox)
Set f = f.Folders("Music Plans")
imax = f.Items.Count

For i = 1 To imax
    Set msg = f.Items(i)
Next