This documentation is archived and is not being maintained.

GetNameSpace Method

Office 2003

Returns a NameSpace object of the specified type.


expression     Required. An expression that returns an Application object.

Type    Required String. The type of name space to return.


The only supported name space type is "MAPI". The GetNameSpace method is functionally equivalent to the Session property, which was introduced in Microsoft Outlook 98.


This Visual Basic for Applications (VBA) example uses the CurrentFolder property to change the displayed folder to the user's Calendar folder.

Sub ChangeCurrentFolder()
	Dim myolApp As Outlook.Application
	Dim myNamespace As Outlook.NameSpace
	Set myolApp = CreateObject("Outlook.Application")
	Set myNamespace = myolApp.GetNamespace("MAPI")
	Set myolApp.ActiveExplorer.CurrentFolder = _
End Sub

If you use Microsoft Visual Basic Scripting Edition (VBScript) in an Outlook form, you do not create the Application object, and you cannot use named constants. This example shows how to perform the same task using VBScript code.

Sub CommandButton1_Click()
 Set myNameSpace = Application.GetNameSpace("MAPI")
 Set Application.ActiveExplorer.CurrentFolder = _
End Sub

Applies to | Application Object