CurrentUser Property Example

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

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
MsgBox myNameSpace.CurrentUser.Name

If you use VBScript, you do not create the Application object. This example shows how to perform the same task using VBScript.

Set myNameSpace = Application.GetNameSpace("MAPI")
MsgBox myNameSpace.CurrentUser.Name