Here's an interesting scenario.
I would like to create a treeview that shows the outlook folders (Inbox and Sent Items) and their sub folders, obviously in the order they appear in outlook:
[Inbox]
|----[Work]
|------|------ [In Progress]
|------|------ [Finished]
|----[Personal]
|------|------ [Jokes]
|------|------ [Job Apps]
[Sent Items]
|----[Clients]
|----[Personal]
|------|------[My Mates]
After a bit of investigation, I discovered that to get all of these folders, I would need to use recursiveness on the outlook objects: thus came to this (with a bit of help from google, and an author who I do not have their name to credit.. sorry!):
The next stage is to load this detail into the node list.
However, I'm unsure of how to use recursion to add these items into the the treeview. I'm pretty sure that I'm not that far away with the above, and perhaps need little coding to make this work.
Are you able to help? Thanks,
Si
------------------------
Hit any User to continue
I would like to create a treeview that shows the outlook folders (Inbox and Sent Items) and their sub folders, obviously in the order they appear in outlook:
[Inbox]
|----[Work]
|------|------ [In Progress]
|------|------ [Finished]
|----[Personal]
|------|------ [Jokes]
|------|------ [Job Apps]
[Sent Items]
|----[Clients]
|----[Personal]
|------|------[My Mates]
After a bit of investigation, I discovered that to get all of these folders, I would need to use recursiveness on the outlook objects: thus came to this (with a bit of help from google, and an author who I do not have their name to credit.. sorry!):
Code:
Private Sub StartOutlookRecursion
Dim olApp As Outlook.Application
Dim olNamespace As Outlook.NameSpace
Dim olFolder As MAPIFolder
Set olApp = CreateObject("Outlook.Application")
Set olNamespace = olApp.GetNamespace("MAPI")
Set olFolder = olNamespace.GetDefaultFolder(olFolderInbox)
Call OutputFolderDetails(olFolder)
End Sub
Code:
Private Sub OutputFolderDetails(olFolder As MAPIFolder)
Dim objItem As Object
If fldFolder.Folders.Count > 0 Then
For Each objItem In fldFolder.Folders
Call OutputFolderDetails(objItem)
Next objItem
End If
Debug.Print "Folder '" & olFolder.Name & "' (Contains " & olFolder.Items.Count & " items) is a child of " & olFolder.Parent
'Outputs somthing like this:
'Folder 'Inbox' (Contains 2 items) and is a child of Mailbox - Joe Bloggs
End Sub
The next stage is to load this detail into the node list.
However, I'm unsure of how to use recursion to add these items into the the treeview. I'm pretty sure that I'm not that far away with the above, and perhaps need little coding to make this work.
Are you able to help? Thanks,
Si
------------------------
Hit any User to continue