How do i access a specific folder in Outlook97 and all the mail messages inside it?
including access to the mail's attachment.
Printable View
How do i access a specific folder in Outlook97 and all the mail messages inside it?
including access to the mail's attachment.
I use Outlook 2000 but I guess this code should work with Outlook 97 as well.
The secret is to set the Outlook.MailItem. Experiment with that object.Code:Private ol As Outlook.Application
Private Sub Form_Load()
Dim ns As Outlook.NameSpace
Dim mfl As Outlook.MAPIFolder
Dim omi As Outlook.MailItem
Dim i%
On Error Resume Next
Set ol = GetObject(, "Outlook.Application")
If Err Then
Err.Clear
Set ol = CreateObject("Outlook.Application")
End If
Set mfl = ol.GetNamespace("MAPI").Folders("NameOfTopFolder").Folders("NameOfSubFolder")
For Each omi In mfl.Items
MsgBox omi.Body
Next
End Sub
Good luck!