View Single Post
  #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.



Ads