Results 1 to 8 of 8

Thread: i know i'm asking the impossible... :-)

  1. #1

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727

    i know i'm asking the impossible... :-)

    ... but i like to dream!

    is there a freeware activex control that could easily show me a treeview of the outlook folders available?

    i just need a user to select a folder of his outlook... you might have code for this, i'm surely starting to have trouble!!

    thank you, at least for reading till here!!

    cheers,
    w.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  2. #2
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    I'll whip an example up for you

    Gimme a sec

    1600 - sorry couldn't resist

  3. #3
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    VB Code:
    1. Private Sub cmdGetFolders_Click()
    2. 'Required Treeview Control named tvw
    3. 'Reference to Microsoft Outlook 9.0 Object Library
    4.     Dim oApp As Outlook.Application
    5.     Dim oNameSpace As NameSpace
    6.     Dim oFolder As MAPIFolder
    7.     Dim oMailItem As Object
    8.     Dim cFolder As MAPIFolder
    9.     Dim sFolder As MAPIFolder
    10.     Dim myItems As Items
    11.     Dim MailCounter As Integer, FolderCount As Integer
    12.     Dim sMessage As String
    13.     Set oApp = New Outlook.Application
    14.     Set oNameSpace = oApp.GetNamespace("MAPI")
    15.     Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
    16.     tvw.Nodes.Add , , "inbox", oFolder
    17.     For FolderCount = 1 To oFolder.Folders.Count
    18.         Set cFolder = oFolder.Folders(FolderCount)
    19.         tvw.Nodes.Add "inbox", tvwChild, "mail" & FolderCount, cFolder
    20.         If cFolder.Folders.Count <> 0 Then 'check for 1 more layer of sub folders
    21.             For nfoldercount = 1 To oFolder.Folders.Count
    22.                 Set sFolder = oFolder.Folders(nfoldercount)
    23.                 If sFolder <> cFolder Then tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mail" & FolderCount & nfoldercount, sFolder
    24.             Next
    25.         End If
    26.     Next
    27.     Set oMailItem = Nothing
    28.     Set oFolder = Nothing
    29.     Set mFolder = Nothing
    30.     Set oNameSpace = Nothing
    31.     Set oApp = Nothing
    32. End Sub

    how's that for you?

  4. #4

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727

    looks more than nice!

    thank you very much for this ;-)

    just parsing through the code i can't really understand if the parsing of all the folders is done as it constantly refers to the default inbox one... i'll test it as soon as i get in front of my computer at home, i'm really looking forward ;-)

    do you happen to know if this will work with outlook express too?

    really, thanks a lot,
    w.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  5. #5
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    This adjustment adds message subjects to the appropriate node, just in case you wanted that:

    VB Code:
    1. Private Sub cmdGetFolders_Click()
    2. 'Required Treeview Control named tvw
    3. 'Reference to Microsoft Outlook 9.0 Object Library
    4.     Dim oApp As Outlook.Application
    5.     Dim oNameSpace As NameSpace
    6.     Dim oFolder As MAPIFolder
    7.     Dim oMailItem As Object
    8.     Dim cFolder As MAPIFolder
    9.     Dim sFolder As MAPIFolder
    10.     Dim myItems As Items
    11.     Dim MailCounter As Integer, FolderCount As Integer
    12.     Dim sMessage As String
    13.     Set oApp = New Outlook.Application
    14.     Set oNameSpace = oApp.GetNamespace("MAPI")
    15.     Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
    16.     tvw.Nodes.Add , , "inbox", oFolder
    17.     mCounter = 0
    18.     For Each oMailItem In oFolder.Items
    19.     mCounter = mCounter + 1
    20.             tvw.Nodes.Add "inbox", tvwChild, "mailmsg" & mCounter, "MAIL: " & oMailItem
    21.         Next
    22.     For FolderCount = 1 To oFolder.Folders.Count
    23.         Set cFolder = oFolder.Folders(FolderCount)
    24.         tvw.Nodes.Add "inbox", tvwChild, "mail" & FolderCount, cFolder
    25.         For Each oMailItem In cFolder.Items
    26.         mCounter = mCounter + 1
    27.             tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mailmsg" & mCounter, "MAIL: " & oMailItem
    28.         Next
    29.         If cFolder.Folders.Count <> 0 Then 'check for 1 more layer of sub folders
    30.             For nFolderCount = 1 To oFolder.Folders.Count
    31.                 Set sFolder = oFolder.Folders(nFolderCount)
    32.                 If sFolder <> cFolder Then
    33.                 tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mail" & FolderCount & nFolderCount, sFolder
    34.                 For Each oMailItem In sFolder.Items
    35.                     mCounter = mCounter + 1
    36.                     tvw.Nodes.Add "mail" & FolderCount & nFolderCount, tvwChild, "mailmsg" & mCounter, "MAIL: " & oMailItem
    37.                    Next
    38.                    End If
    39.             Next
    40.         End If
    41.     Next
    42.     Set oMailItem = Nothing
    43.     Set oFolder = Nothing
    44.     Set mFolder = Nothing
    45.     Set oNameSpace = Nothing
    46.     Set oApp = Nothing
    47. End Sub

  6. #6
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Re: looks more than nice!

    Originally posted by wildcat_2000
    thank you very much for this ;-)

    just parsing through the code i can't really understand if the parsing of all the folders is done as it constantly refers to the default inbox one... i'll test it as soon as i get in front of my computer at home, i'm really looking forward ;-)

    do you happen to know if this will work with outlook express too?

    really, thanks a lot,
    w.
    just make sure you have subfolders for it to loop thru.

    i don't think it would work with outlook express though..

    i'll see if i can fix it if it doesn't

  7. #7

    Thread Starter
    Fanatic Member wildcat_2000's Avatar
    Join Date
    Nov 2000
    Location
    Italy
    Posts
    727
    wow i'm not really sure i'll be able to make it up to you for, especially for the quickness of your response!

    and yes i was actually looking to add information, but i'll just add the name of the senders instead of the subject line :-)

    hope this does work with express!!

    thanks thanks and thanks,

    w.
    When your car breaks down,
    close all windows and retry

    => please rate all users posts! <=

  8. #8
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    don't mention it...
    here is the other code,
    it adds the sendername instead

    VB Code:
    1. 'Required Treeview Control named tvw
    2. 'Reference to Microsoft Outlook 9.0 Object Library
    3.     Dim oApp As Outlook.Application
    4.     Dim oNameSpace As NameSpace
    5.     Dim oFolder As MAPIFolder
    6.     Dim oMailItem As MailItem
    7.     Dim cFolder As MAPIFolder
    8.     Dim sFolder As MAPIFolder
    9.     Dim myItems As Items
    10.     Dim MailCounter As Integer, FolderCount As Integer
    11.     Dim sMessage As String
    12.     Set oApp = New Outlook.Application
    13.     Set oNameSpace = oApp.GetNamespace("MAPI")
    14.     Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
    15.     tvw.Nodes.Add , , "inbox", oFolder
    16.     mCounter = 0
    17.     For Each oMailItem In oFolder.Items
    18.     mCounter = mCounter + 1
    19.             tvw.Nodes.Add "inbox", tvwChild, "mailmsg" & mCounter, "MAILSENDER: " & oMailItem.SenderName
    20.         Next
    21.     For FolderCount = 1 To oFolder.Folders.Count
    22.         Set cFolder = oFolder.Folders(FolderCount)
    23.         tvw.Nodes.Add "inbox", tvwChild, "mail" & FolderCount, cFolder
    24.         For Each oMailItem In cFolder.Items
    25.         mCounter = mCounter + 1
    26.             tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mailmsg" & mCounter, "MAILSENDER: " & oMailItem.SenderName
    27.         Next
    28.         If cFolder.Folders.Count <> 0 Then 'check for 1 more layer of sub folders
    29.             For nFolderCount = 1 To oFolder.Folders.Count
    30.                 Set sFolder = oFolder.Folders(nFolderCount)
    31.                 If sFolder <> cFolder Then
    32.                 tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mail" & FolderCount & nFolderCount, sFolder
    33.                 For Each oMailItem In sFolder.Items
    34.                     mCounter = mCounter + 1
    35.                     tvw.Nodes.Add "mail" & FolderCount & nFolderCount, tvwChild, "mailmsg" & mCounter, "MAILSENDER: " & oMailItem.SenderName
    36.                    Next
    37.                    End If
    38.             Next
    39.         End If
    40.     Next
    41.     Set oMailItem = Nothing
    42.     Set oFolder = Nothing
    43.     Set mFolder = Nothing
    44.     Set oNameSpace = Nothing
    45.     Set oApp = Nothing

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