|
-
Oct 10th, 2001, 06:41 AM
#1
Thread Starter
Fanatic Member
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! <=
-
Oct 10th, 2001, 06:55 AM
#2
Conquistador
I'll whip an example up for you
Gimme a sec
1600 - sorry couldn't resist
-
Oct 10th, 2001, 07:17 AM
#3
Conquistador
VB Code:
Private Sub cmdGetFolders_Click()
'Required Treeview Control named tvw
'Reference to Microsoft Outlook 9.0 Object Library
Dim oApp As Outlook.Application
Dim oNameSpace As NameSpace
Dim oFolder As MAPIFolder
Dim oMailItem As Object
Dim cFolder As MAPIFolder
Dim sFolder As MAPIFolder
Dim myItems As Items
Dim MailCounter As Integer, FolderCount As Integer
Dim sMessage As String
Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
tvw.Nodes.Add , , "inbox", oFolder
For FolderCount = 1 To oFolder.Folders.Count
Set cFolder = oFolder.Folders(FolderCount)
tvw.Nodes.Add "inbox", tvwChild, "mail" & FolderCount, cFolder
If cFolder.Folders.Count <> 0 Then 'check for 1 more layer of sub folders
For nfoldercount = 1 To oFolder.Folders.Count
Set sFolder = oFolder.Folders(nfoldercount)
If sFolder <> cFolder Then tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mail" & FolderCount & nfoldercount, sFolder
Next
End If
Next
Set oMailItem = Nothing
Set oFolder = Nothing
Set mFolder = Nothing
Set oNameSpace = Nothing
Set oApp = Nothing
End Sub
how's that for you?
-
Oct 10th, 2001, 07:26 AM
#4
Thread Starter
Fanatic Member
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! <=
-
Oct 10th, 2001, 07:27 AM
#5
Conquistador
This adjustment adds message subjects to the appropriate node, just in case you wanted that:
VB Code:
Private Sub cmdGetFolders_Click()
'Required Treeview Control named tvw
'Reference to Microsoft Outlook 9.0 Object Library
Dim oApp As Outlook.Application
Dim oNameSpace As NameSpace
Dim oFolder As MAPIFolder
Dim oMailItem As Object
Dim cFolder As MAPIFolder
Dim sFolder As MAPIFolder
Dim myItems As Items
Dim MailCounter As Integer, FolderCount As Integer
Dim sMessage As String
Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
tvw.Nodes.Add , , "inbox", oFolder
mCounter = 0
For Each oMailItem In oFolder.Items
mCounter = mCounter + 1
tvw.Nodes.Add "inbox", tvwChild, "mailmsg" & mCounter, "MAIL: " & oMailItem
Next
For FolderCount = 1 To oFolder.Folders.Count
Set cFolder = oFolder.Folders(FolderCount)
tvw.Nodes.Add "inbox", tvwChild, "mail" & FolderCount, cFolder
For Each oMailItem In cFolder.Items
mCounter = mCounter + 1
tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mailmsg" & mCounter, "MAIL: " & oMailItem
Next
If cFolder.Folders.Count <> 0 Then 'check for 1 more layer of sub folders
For nFolderCount = 1 To oFolder.Folders.Count
Set sFolder = oFolder.Folders(nFolderCount)
If sFolder <> cFolder Then
tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mail" & FolderCount & nFolderCount, sFolder
For Each oMailItem In sFolder.Items
mCounter = mCounter + 1
tvw.Nodes.Add "mail" & FolderCount & nFolderCount, tvwChild, "mailmsg" & mCounter, "MAIL: " & oMailItem
Next
End If
Next
End If
Next
Set oMailItem = Nothing
Set oFolder = Nothing
Set mFolder = Nothing
Set oNameSpace = Nothing
Set oApp = Nothing
End Sub
-
Oct 10th, 2001, 07:28 AM
#6
Conquistador
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
-
Oct 10th, 2001, 07:32 AM
#7
Thread Starter
Fanatic Member
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! <=
-
Oct 10th, 2001, 04:19 PM
#8
Conquistador
don't mention it...
here is the other code,
it adds the sendername instead
VB Code:
'Required Treeview Control named tvw
'Reference to Microsoft Outlook 9.0 Object Library
Dim oApp As Outlook.Application
Dim oNameSpace As NameSpace
Dim oFolder As MAPIFolder
Dim oMailItem As MailItem
Dim cFolder As MAPIFolder
Dim sFolder As MAPIFolder
Dim myItems As Items
Dim MailCounter As Integer, FolderCount As Integer
Dim sMessage As String
Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
tvw.Nodes.Add , , "inbox", oFolder
mCounter = 0
For Each oMailItem In oFolder.Items
mCounter = mCounter + 1
tvw.Nodes.Add "inbox", tvwChild, "mailmsg" & mCounter, "MAILSENDER: " & oMailItem.SenderName
Next
For FolderCount = 1 To oFolder.Folders.Count
Set cFolder = oFolder.Folders(FolderCount)
tvw.Nodes.Add "inbox", tvwChild, "mail" & FolderCount, cFolder
For Each oMailItem In cFolder.Items
mCounter = mCounter + 1
tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mailmsg" & mCounter, "MAILSENDER: " & oMailItem.SenderName
Next
If cFolder.Folders.Count <> 0 Then 'check for 1 more layer of sub folders
For nFolderCount = 1 To oFolder.Folders.Count
Set sFolder = oFolder.Folders(nFolderCount)
If sFolder <> cFolder Then
tvw.Nodes.Add "mail" & FolderCount, tvwChild, "mail" & FolderCount & nFolderCount, sFolder
For Each oMailItem In sFolder.Items
mCounter = mCounter + 1
tvw.Nodes.Add "mail" & FolderCount & nFolderCount, tvwChild, "mailmsg" & mCounter, "MAILSENDER: " & oMailItem.SenderName
Next
End If
Next
End If
Next
Set oMailItem = Nothing
Set oFolder = Nothing
Set mFolder = Nothing
Set oNameSpace = Nothing
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|