CurrentUser Property

Microsoft Outlook Visual Basic

Returns the display name of the currently logged-on user as a Recipient object. Read-only.

expression.CurrentUser

expression     Required. An expression that returns a NameSpace object.

Remarks

Outlook blocks code that attempts to access the CurrentUser property for security reasons. If you run a third-party add-in, custom solution, or other program that uses the CurrentUser property in Office Outlook 2003, you may receive the following warning:

A program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this? If this is unexpected, it may be a virus and you should choose "No".

Example

This Visual Basic for Applications (VBA) example uses the CurrentUser property to obtain the name of the currently logged-on user and then displays a message box containing the name.

Sub DisplayCurrentUser()
	Dim myolApp As Outlook.Application
	Dim myNamespace As Outlook.NameSpace
	Set myOlApp = CreateObject("Outlook.Application")
	Set myNameSpace = myOlApp.GetNameSpace("MAPI")
	MsgBox myNameSpace.CurrentUser
End Sub
		

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

Sub CommandButton1_Click()
 Set myNameSpace = Application.GetNameSpace("MAPI")
 MsgBox myNameSpace.CurrentUser
End Sub