473,511 Members | 15,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

MAPI Folder Tree Navigation

In effort to understand (Outlook) MAPI folder tree
structure wrote simple linear code below to navigate
tree.

Successive "...Folders.GetNext()"'s return same folder at
all levels of tree. What am I doing wrong or not
understanding?

Thanks.

OUTPUT:
There are 4 root folders.
Root Folder 1 name: Public Folders
Public Folders contains 2 folders.
Level 1 folder 1 name: Favorites
Level 1 folder 2 name: All Public Folders
Level 1 folder 3 name: All Public Folders
Level 1 folder 4 name: All Public Folders
Root Folder 2 name: Mailbox - Doe, John
Mailbox - Doe, John contains 15 folders.
Level 1 folder name: Calendar
Level 1 folder name: Contacts
Level 1 folder name: Contacts
Root folder 3 name: Mailbox - Doe, John
....

CODE:
Private Sub btnGo_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnGo.Click
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim oRootFolder As Outlook.MAPIFolder
Dim oFolder As Outlook.MAPIFolder
Dim strText As New System.Text.StringBuilder()

olApp = CreateObject("Outlook.Application")
olNS = olApp.GetNamespace("MAPI")

'Get root MAPIFolder
strText.Append("There are " & olNS.Folders.Count
() & " root folders." & vbCrLf)
oRootFolder = olNS.Folders.GetFirst()
strText.Append("Root Folder 1 name: " &
oRootFolder.Name & vbCrLf)
strText.Append(vbTab & oRootFolder.Name.ToString
() & " contains " & oRootFolder.Folders.Count.ToString()
& " folders." & vbCrLf)

'Get next level MAPIFolder
oFolder = oRootFolder.Folders.GetFirst()
strText.Append(vbTab & "Level 1 folder 1 name: "
& oFolder.Name & vbCrLf)
oFolder = oRootFolder.Folders.GetNext()
strText.Append(vbTab & "Level 1 folder 2 name: "
& oFolder.Name & vbCrLf)
oFolder = oRootFolder.Folders.GetNext()
strText.Append(vbTab & "Level 1 folder 3 name: "
& oFolder.Name & vbCrLf)
oFolder = oRootFolder.Folders.GetNext()
strText.Append(vbTab & "Level 1 folder 4 name: "
& oFolder.Name & vbCrLf)

'Get next root MAPIFolder
oRootFolder = olNS.Folders.GetNext()
strText.Append("Root Folder 2 name: " &
oRootFolder.Name & vbCrLf)
strText.Append(oRootFolder.Name & " contains " &
oRootFolder.Folders.Count.ToString() & " folders." &
vbCrLf)

'Get next level MAPIFolder
oFolder = oRootFolder.Folders.GetFirst()
strText.Append(vbTab & "Level 1 folder name: " &
oFolder.Name & vbCrLf)
oFolder = oRootFolder.Folders.GetNext()
strText.Append(vbTab & "Level 1 folder name: " &
oFolder.Name & vbCrLf)
oFolder = oRootFolder.Folders.GetNext()
strText.Append(vbTab & "Level 1 folder name: " &
oFolder.Name & vbCrLf)

'Get next root MAPIFolder
oRootFolder = olNS.Folders.GetNext()
strText.Append("Root folder 3 name: " &
oRootFolder.Name & vbCrLf)

rtxtShow.Text = strText.ToString()
End Sub

Nov 15 '05 #1
0 3300

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
7176
by: Kurt | last post by:
Hi I am using CDO 1.21 from C# in order to iterate through the entries in a users outlook address book (as OOM was too slow). Basically I take the Name field from each "message" and insert it into...
0
1729
by: Oleg Safronov via .NET 247 | last post by:
I'm trying to read properties of journal item which is stored in Exchange public folder. I already have access to journal item via CDO.Item object. However, it does not allow reading of...
6
2717
by: Dennis Allen | last post by:
Hi. I was wondering if someone here could help me. My web site has a very simple folder tree menu bar. Example: <a id="club_t" href="##" onclick="return Outline(this)"><img id="club_i" alt=""...
7
4179
by: Ottar | last post by:
I've made a program sorting incomming mail in public folder. The function runs every minute by using the form.timer event. In Access XP it runs for weeks, no problem. Access 2003 runs the same...
0
1086
by: Tomas Brabenec | last post by:
Hi all, i need open new messages in default e-mail client from my application in windows. I using simplemapi.py (http://www.kirbyfooty.com/simplemapi.py) But not worked correctly. This is a...
3
2821
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
1
5110
by: netLynx | last post by:
Hi, I am rewriting code from VB6 using MAPI into VB.NET I need to read an attachment off an email on an Exchange Server. In the old VB6 (not written by me) they restrict the Messages.type to...
0
1659
by: OSI Mik | last post by:
Hi, Sorry for this question but I can't find information about it. I try to connect to Exchange by MAPI or CDO to create folder in mailbox of some user. I found code like that : Dim...
3
31804
by: GayathriP | last post by:
This article discusses about how can we access the inbox through MAPI using C# .NET. It also discusses about how to store the attachment in the local directory, how to create a folder in the inbox ...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7371
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5676
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5077
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
452
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.