Export (0) Print
Expand All

GetNameSpace Method

Office 2003

Returns a NameSpace object of the specified type.

expression.GetNameSpace(Type)

expression     Required. An expression that returns an Application object.

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

Remarks

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.

Example

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 = _
	myNamespace.GetDefaultFolder(olFolderCalendar)
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 = _
 myNameSpace.GetDefaultFolder(9)
End Sub
		


Applies to | Application Object



Show:
© 2014 Microsoft