Free Web Hosting Provider - Web Hosting - E-commerce - High Speed Internet - Free Web Page
Search the Web

MW-Menu

 

Free Visual BASIC Newsletter

Features

Tips

Sample Code

Newsletters

Products

ActiveX

Cool Links

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Open a Custom Folder in Microsoft Outlook

"MEGA" Tip: How to open a custom Outlook folder and enumerate through its contents?

If you use Microsoft Outlook and you have a sub folder of say the inbox, where you may filter items to, you can open this folder and enumerate through its contents using the following method:

Sub GetFolderContents()

Dim oOutlook As New Outlook.Application

Dim oNameSpace As NameSpace

Dim oFolder As MAPIFolder

Dim oMyFolder As MAPIFolder

Dim oMyFolder2 As MAPIFolder

Dim iPos As Integer

Set oNameSpace = oOutlook.GetNamespace("MAPI")

Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)

' Open the inbox. NB This could be any default folder

' like the 'Contacts'.

Set oMyFolder = oFolder.Folders("Newsletters")

' If there is a subfolder of the folder you have

' opened then you need to use the same technique

' again, like below, which is a subfolder of the

' above folder.

'Set oMyFolder2 = oMyFolder.Folders("Other")

For iPos = 1 To oMyFolder2.Items.Count

' Loop through the messages.

Debug.Print oMyFolder2.Items(iPos).Subject

' Print the messages subject to the debug.

Next

Set oFolder = Nothing

Set oNameSpace = Nothing

Set oOutlook = Nothing

' Remove instances and free up memory

End Sub

If this example the Inbox is opened and then the Newsletters folder (substitute in your own folder name) and then if there is another sub folder, open that using the same technique.

Home

___________________________________________

Send Bugs, comments to the webmaster at webmaster@mwe.8m.com

Terms of Use

© 1999 MW Software, all rights reserved