Results 1 to 5 of 5

Thread: Populating Treeview from Outlook

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    33

    Populating Treeview from Outlook

    Hi everyone.

    I would like to add my email Inbox folders (and nested subfolders) to a treeview and have no clue where to begin.
    I've searched online for the past couple of hours but unfortunately Google is not my friend today.

    Could anyone please point me in the right direction?

    Thanks in advance

  2. #2

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    33

    Re: Populating Treeview from Outlook

    Bump. Please help.

    Not looking for any code (although that would be helpful), I'm just wondering where I should be looking.

    Thanks folks

  3. #3
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,949
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

  4. #4

    Thread Starter
    Member
    Join Date
    Dec 2009
    Posts
    33

    Re: Populating Treeview from Outlook

    Thanks KG.

    Don't mean to be rude, but those don't exactly answer my question. your time wasn't waisted though, because one of your links gave me the answer to something else I was trying to do.


    What I'm trying to do is retrieve the Folder names in my inbox and list them in a treeview.

    I finally figured it out (sort of)...

    This is what I have so far but all my folders are "flat" and the SubFolders are all shown at the top level.

    Code:
    Private Sub AddFoldersToTree(ThisInbox As Outlook.MAPIFolder)
            Dim mySbFldr As Outlook.MAPIFolder
            NodeCnt = NodeCnt + 1
    		
            For Each SbFldr In ThisInbox.Folders
                TreeView1.Nodes.Add(SbFldr.Name & NodeCnt, SbFldr.Name)
    	    AddEmailFolderToTree(SbFldr, SbFldr.Name & NodeCnt)
            Next SbFldr
    End Sub
    So for example I want my treeview to look something like this.

    Code:
    +Personal Inbox
    -Work Inbox
    	|_Staff
    		|_Anne Jameson
    		|_Peter Smith
    		|_Steve Jones
    	|_Suppliers
    		|_Goggles
    		|_Kinkos
    			|_Retail
    			|_Wholesale
    		|_Tesco

    But at the moment it's showing this

    Code:
    Work Inbox
    Staff
    Anne Jameson
    Peter Smith
    Steve Jones
    Suppliers
    Goggles
    Kinkos
    Retail
    Wholesale
    Tesco

    Thanks

  5. #5
    Frenzied Member KGComputers's Avatar
    Join Date
    Dec 2005
    Location
    Cebu, PH
    Posts
    1,949

    Re: Populating Treeview from Outlook

    Hi,

    Work Inbox
    Staff
    Anne Jameson
    Peter Smith
    Steve Jones
    Suppliers
    Goggles
    Kinkos
    Retail
    Wholesale
    Tesco

    It's flat because in this code:
    vb.net Code:
    1. For Each SbFldr In ThisInbox.Folders
    2.             TreeView1.Nodes.Add(SbFldr.Name & NodeCnt, SbFldr.Name)
    3.         AddEmailFolderToTree(SbFldr, SbFldr.Name & NodeCnt)
    4. Next SbFldr
    each node were set as parent. You need to add the other nodes as children.

    Sample Code:
    vb.net Code:
    1. TrvNode = New TreeNode
    2. TrvNode.Text= "yourtext"
    3. TrvNode.Name= "your_name"
    4. TreeView1.Nodes(0).Nodes(2).Nodes.Add(TrvNode)

    MSDN Treeview
    vb.net Code:
    1. ' Populates a TreeView control with example nodes.  
    2. Private Sub InitializeTreeView()
    3.     treeView1.BeginUpdate()
    4.     treeView1.Nodes.Add("Parent")
    5.     treeView1.Nodes(0).Nodes.Add("Child 1")
    6.     treeView1.Nodes(0).Nodes.Add("Child 2")
    7.     treeView1.Nodes(0).Nodes(1).Nodes.Add("Grandchild")
    8.     treeView1.Nodes(0).Nodes(1).Nodes(0).Nodes.Add("Great Grandchild")
    9.     treeView1.EndUpdate()
    10. End Sub

    display-hierarchical-data-in-vbnet-with-the-treeview-control/
    Last edited by KGComputers; Jun 5th, 2014 at 01:44 AM.
    CodeBank: VB.NET & C#.NET | ASP.NET
    Programming: C# | VB.NET
    Blogs: Personal |Programming | GitHub
    ___________________________________________________________________________________

    Rating someone's post is a way of saying Thanks...

Tags for this Thread

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