Recurively Iterate through folder tree? 
Author Message
 Recurively Iterate through folder tree?

Does anyone have a routine that will iterate through a folder tree
recursively? I'm trying to write a routine that will copy a given folder
tree from a pst store. I just need a little help with the recursion. Keep
trying and hurting my brain.
Any help would be appreciated!
Jeff


Tue, 16 Aug 2005 10:22:01 GMT  
 Recurively Iterate through folder tree?
Hi, Jeff!
Quote:
> Does anyone have a routine that will iterate through a folder tree
> recursively? I'm trying to write a routine that will copy a given folder
> tree from a pst store. I just need a little help with the recursion. Keep
> trying and hurting my brain.
> Any help would be appreciated!
> Jeff

 How about such function:
Public Function GetChildFolder(oParentFolder As MAPIFolder, FolderName As
String) As MAPIFolder
'Return MAPIFolder with name FolderName
'contained in the folder oParentFolder or its children (or Nothing)
'!!!Folder names are not unique and this function return only first such
folder
    Dim oFold As MAPIFolder
    Dim oCurFold As MAPIFolder
    If oParentFolder.Folders.Count = 0 Then
        Set GetChildFolder = Nothing
        Exit Function
    Else
        On Error Resume Next
        Set GetChildFolder = oParentFolder.Folders(FolderName)
        If Err.Number = 0 Then
           Exit Function
        Else
            For Each oCurFold In oParentFolder.Folders
                Set oFold = GetChildFolder(oCurFold, FolderName)
                If Not (oFold Is Nothing) Then
                    Set GetChildFolder = oFold
                    Exit Function
                End If
            Next
        End If
    End If
End Function

With best regards,
Vlad Korol



Tue, 16 Aug 2005 17:56:38 GMT  
 Recurively Iterate through folder tree?
Thanks Vlad,
That was the ticket!


Quote:
> Hi, Jeff!
> > Does anyone have a routine that will iterate through a folder tree
> > recursively? I'm trying to write a routine that will copy a given folder
> > tree from a pst store. I just need a little help with the recursion.
Keep
> > trying and hurting my brain.
> > Any help would be appreciated!
> > Jeff
>  How about such function:
> Public Function GetChildFolder(oParentFolder As MAPIFolder, FolderName As
> String) As MAPIFolder
> 'Return MAPIFolder with name FolderName
> 'contained in the folder oParentFolder or its children (or Nothing)
> '!!!Folder names are not unique and this function return only first such
> folder
>     Dim oFold As MAPIFolder
>     Dim oCurFold As MAPIFolder
>     If oParentFolder.Folders.Count = 0 Then
>         Set GetChildFolder = Nothing
>         Exit Function
>     Else
>         On Error Resume Next
>         Set GetChildFolder = oParentFolder.Folders(FolderName)
>         If Err.Number = 0 Then
>            Exit Function
>         Else
>             For Each oCurFold In oParentFolder.Folders
>                 Set oFold = GetChildFolder(oCurFold, FolderName)
>                 If Not (oFold Is Nothing) Then
>                     Set GetChildFolder = oFold
>                     Exit Function
>                 End If
>             Next
>         End If
>     End If
> End Function

> With best regards,
> Vlad Korol



Wed, 17 Aug 2005 04:10:24 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Recurively Iterate through folder tree?

2. Iterate thru folders-messages - Outlook

3. Iterating through all subfolders in a Public Folder

4. Iterating through the contacts folder

5. Iterate through ALL folders

6. Iterating through folders?

7. VBA add other users mailboxes to the outlook explorer / folder tree

8. File Explorer in a Tree View box, but displaying only one folder

9. tree structure (expanding collapsing explorer folder style)

10. Running on a folder tree with variable in the middle

11. Need a folder tree

12. HOW TO DISPLAY A FOLDER TREE IN ASP WEB PAGE

 

 
Powered by phpBB® Forum Software