A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Folders & Subfolders



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 10th 09, 12:30 AM posted to microsoft.public.outlook.program_vba
Marvin Buzz
external usenet poster
 
Posts: 9
Default Folders & Subfolders

I am writing in Visual Basic, not VBA. I can write the code to identify all
of the subfolders in Outlook, but do not know how to program for the
subfolders of the subfolders...subfolders to any possible depth of subfolders.

Any samples or guidance would be very much appreciated.

Thanks in advance.

Ads
  #2  
Old July 10th 09, 12:48 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Folders & Subfolders

Each Folder in Outlook 2007 or MAPIFolder in earlier versions has a Folders
collection containing all its subfolders. Each subfolder in a Folders
collection has a unique name, so you can return any subfolder with an
expression like this:

myParentFolder.Folders("Name of subfolder")

The code sample at http://www.outlookcode.com/codedetail.aspx?id=628 shows
how to process all the folders below a given starting folder.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Marvin Buzz" wrote in message
...
I am writing in Visual Basic, not VBA. I can write the code to identify
all
of the subfolders in Outlook, but do not know how to program for the
subfolders of the subfolders...subfolders to any possible depth of
subfolders.

Any samples or guidance would be very much appreciated.

Thanks in advance.



  #3  
Old July 10th 09, 02:48 PM posted to microsoft.public.outlook.program_vba
Alan Moseley
external usenet poster
 
Posts: 61
Default Folders & Subfolders

You need to write a sub or function that is recursively called by itself.
For example:-

Public Sub ProcessAllFolders()
Dim fld As MAPIFolder
For Each fld In Application.GetNamespace("MAPI").Folders
Call ProcessFolder(fld)
Next fld
End Sub

Public Sub ProcessFolder(ByRef fld As MAPIFolder)
Dim subfld As MAPIFolder
'Do Something here
For Each subfld In fld.Folders
Call ProcessFolder(subfld)
Next subfld
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Marvin Buzz" wrote:

I am writing in Visual Basic, not VBA. I can write the code to identify all
of the subfolders in Outlook, but do not know how to program for the
subfolders of the subfolders...subfolders to any possible depth of subfolders.

Any samples or guidance would be very much appreciated.

Thanks in advance.

  #4  
Old July 10th 09, 04:04 PM posted to microsoft.public.outlook.program_vba
Marvin Buzz
external usenet poster
 
Posts: 9
Default Folders & Subfolders

I am getting a compiler error that says I cannot define user types.

"Alan Moseley" wrote:

You need to write a sub or function that is recursively called by itself.
For example:-

Public Sub ProcessAllFolders()
Dim fld As MAPIFolder
For Each fld In Application.GetNamespace("MAPI").Folders
Call ProcessFolder(fld)
Next fld
End Sub

Public Sub ProcessFolder(ByRef fld As MAPIFolder)
Dim subfld As MAPIFolder
'Do Something here
For Each subfld In fld.Folders
Call ProcessFolder(subfld)
Next subfld
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Marvin Buzz" wrote:

I am writing in Visual Basic, not VBA. I can write the code to identify all
of the subfolders in Outlook, but do not know how to program for the
subfolders of the subfolders...subfolders to any possible depth of subfolders.

Any samples or guidance would be very much appreciated.

Thanks in advance.

  #5  
Old July 10th 09, 04:13 PM posted to microsoft.public.outlook.program_vba
Alan Moseley
external usenet poster
 
Posts: 61
Default Folders & Subfolders

Firstly add a reference to Outlook within your project. Secondly import the
namespace before the beginning of your class, ie:-

Imports Microsoft.Office.Interop.Outlook

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Marvin Buzz" wrote:

I am getting a compiler error that says I cannot define user types.

"Alan Moseley" wrote:

You need to write a sub or function that is recursively called by itself.
For example:-

Public Sub ProcessAllFolders()
Dim fld As MAPIFolder
For Each fld In Application.GetNamespace("MAPI").Folders
Call ProcessFolder(fld)
Next fld
End Sub

Public Sub ProcessFolder(ByRef fld As MAPIFolder)
Dim subfld As MAPIFolder
'Do Something here
For Each subfld In fld.Folders
Call ProcessFolder(subfld)
Next subfld
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Marvin Buzz" wrote:

I am writing in Visual Basic, not VBA. I can write the code to identify all
of the subfolders in Outlook, but do not know how to program for the
subfolders of the subfolders...subfolders to any possible depth of subfolders.

Any samples or guidance would be very much appreciated.

Thanks in advance.

  #6  
Old July 10th 09, 08:46 PM posted to microsoft.public.outlook.program_vba
Marvin Buzz
external usenet poster
 
Posts: 9
Default Folders & Subfolders

Thanks for your response. I figured out how to add a reference, but I get an
error on the IMPORTS statement that I copied from your prior response. It
says sub or function not defined. I do not understand what you mean by my
"class". The code I am trying to execute is in a form run from VB.

Marvin

"Alan Moseley" wrote:

Firstly add a reference to Outlook within your project. Secondly import the
namespace before the beginning of your class, ie:-

Imports Microsoft.Office.Interop.Outlook

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Marvin Buzz" wrote:

I am getting a compiler error that says I cannot define user types.

"Alan Moseley" wrote:

You need to write a sub or function that is recursively called by itself.
For example:-

Public Sub ProcessAllFolders()
Dim fld As MAPIFolder
For Each fld In Application.GetNamespace("MAPI").Folders
Call ProcessFolder(fld)
Next fld
End Sub

Public Sub ProcessFolder(ByRef fld As MAPIFolder)
Dim subfld As MAPIFolder
'Do Something here
For Each subfld In fld.Folders
Call ProcessFolder(subfld)
Next subfld
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Marvin Buzz" wrote:

I am writing in Visual Basic, not VBA. I can write the code to identify all
of the subfolders in Outlook, but do not know how to program for the
subfolders of the subfolders...subfolders to any possible depth of subfolders.

Any samples or guidance would be very much appreciated.

Thanks in advance.

  #7  
Old July 11th 09, 01:37 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP][_3_]
external usenet poster
 
Posts: 465
Default Folders & Subfolders

You don't need an Imports statement in VB6, only in VB.NET.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"Marvin Buzz" wrote in message
...
Thanks for your response. I figured out how to add a reference, but I get
an
error on the IMPORTS statement that I copied from your prior response. It
says sub or function not defined. I do not understand what you mean by my
"class". The code I am trying to execute is in a form run from VB.

Marvin

"Alan Moseley" wrote:

Firstly add a reference to Outlook within your project. Secondly import
the
namespace before the beginning of your class, ie:-

Imports Microsoft.Office.Interop.Outlook

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Marvin Buzz" wrote:

I am getting a compiler error that says I cannot define user types.

"Alan Moseley" wrote:

You need to write a sub or function that is recursively called by
itself.
For example:-

Public Sub ProcessAllFolders()
Dim fld As MAPIFolder
For Each fld In Application.GetNamespace("MAPI").Folders
Call ProcessFolder(fld)
Next fld
End Sub

Public Sub ProcessFolder(ByRef fld As MAPIFolder)
Dim subfld As MAPIFolder
'Do Something here
For Each subfld In fld.Folders
Call ProcessFolder(subfld)
Next subfld
End Sub

--
Alan Moseley IT Consultancy
http://www.amitc.co.uk

If I have solved your problem, please click Yes below. Thanks.


"Marvin Buzz" wrote:

I am writing in Visual Basic, not VBA. I can write the code to
identify all
of the subfolders in Outlook, but do not know how to program for
the
subfolders of the subfolders...subfolders to any possible depth of
subfolders.

Any samples or guidance would be very much appreciated.

Thanks in advance.



  #8  
Old July 12th 09, 10:11 PM posted to microsoft.public.outlook.program_vba
Marvin Buzz
external usenet poster
 
Posts: 9
Default Folders & Subfolders

Thanks to all who have responded. You have helped a great deal.


"Marvin Buzz" wrote:

I am writing in Visual Basic, not VBA. I can write the code to identify all
of the subfolders in Outlook, but do not know how to program for the
subfolders of the subfolders...subfolders to any possible depth of subfolders.

Any samples or guidance would be very much appreciated.

Thanks in advance.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Script to List Folders/subfolders joshboski Outlook and VBA 2 June 19th 08 01:36 PM
Customizing views for ALL folders/subfolders Trond Svendsen Outlook - General Queries 1 April 1st 08 10:47 AM
Graph of Inbox folders and subfolders Mahsa Pedrami Outlook - Using Contacts 1 September 10th 07 08:57 AM
Columns lost. Fix for all folders and subfolders? Jeff Hofstetter Outlook - General Queries 2 August 7th 06 09:23 PM
Public Folders - Search Subfolders is Greyed Out Chris Briant Outlook - General Queries 1 July 19th 06 03:59 PM


All times are GMT +1. The time now is 12:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.