Results 1 to 2 of 2

Thread: How do i access a specific folder in Outlook97 and all the mail messages inside it, ?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2000
    Posts
    12

    Question

    How do i access a specific folder in Outlook97 and all the mail messages inside it?
    including access to the mail's attachment.

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    I use Outlook 2000 but I guess this code should work with Outlook 97 as well.
    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
    The secret is to set the Outlook.MailItem. Experiment with that object.

    Good luck!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width