Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Enumerating Outlook folders.

Posted on 2001-06-26
2
Medium Priority
?
360 Views
Last Modified: 2012-06-21
Does anyone have any code that will populate a treeview control with the folder structure of an outlook profile? My whole goal is to be able to traverse the folder structure that a user has in thier outlook profile without starting (visibly) outlook.
0
Comment
Question by:raycass
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 800 total points
ID: 6230387
This example needs a reference to Microsoft Outlook Object Library to be added to the project.

Private Sub Command1_Click()
    Dim appOutlook As Outlook.Application
    Dim blnCloseIt As Boolean
    Dim fldFolder As MAPIFolder
    Dim tvnFolder As Node
    On Error Resume Next
    Set appOutlook = GetObject(, "Outlook.Application")
    If appOutlook Is Nothing Then
        Set appOutlook = CreateObject("Outlook.Application")
        blnCloseIt = True
    End If
    With appOutlook.GetNamespace("MAPI")
        Set tvnFolder = TreeView1.Nodes.Add(, , "Mapi", "Mapi Folders")
        tvnFolder.EnsureVisible
        For Each fldFolder In .Folders
            IterateFolders "Mapi", fldFolder, TreeView1
        Next
    End With
    If blnCloseIt Then appOutlook.Quit
    Set appOutlook = Nothing
End Sub

Private Sub IterateFolders(Parent As String, CurrentFolder As MAPIFolder, TView As TreeView)
    Dim fldFolder As MAPIFolder
    Set tvnFolder = TView.Nodes.Add(Parent, tvwChild, CurrentFolder.EntryID, CurrentFolder.Name)
    tvnFolder.EnsureVisible
    For Each fldFolder In CurrentFolder.Folders
        IterateFolders CurrentFolder.EntryID, fldFolder, TView
    Next
End Sub
0
 
LVL 1

Author Comment

by:raycass
ID: 6241010
TimCottee, You rock!

Thanks for the excellet example!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month20 days, 17 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question