This documentation is archived and is not being maintained.

NameSpace.Logon Method

Office 2007
Logs the user on to MAPI, obtaining a MAPI session.


expression.Logon(Profile, Password, ShowDialog, NewSession)

expression   A variable that represents a NameSpace object.


NameRequired/OptionalData TypeDescription
ProfileOptionalVariantThe MAPI profile name, as a String, to use for the session.
PasswordOptionalVariantThe password (if any), as a String, associated with the profile. This parameter exists only for backwards compatibility and for security reasons, it is not recommended for use. Microsoft Oultook will prompt the user to specify a password in most system configurations. This is your logon password and should not be confused with PST passwords.
ShowDialogOptionalVariantTrue to display the MAPI logon dialog box to allow the user to select a MAPI profile.
NewSessionOptionalVariantTrue to create a new Outlook session. Since multiple sessions cannot be created in Outlook, this parameter should be specified as True only if a session does not already exist.


This Microsoft Visual Basic example uses the Logon method to log on to a new session, displaying the dialog box to verify the profile name and enter password.

Visual Basic for Applications
Sub StartOutlook()
    Dim myNameSpace As Outlook.NameSpace
    Set myNameSpace = Application.GetNamespace("MAPI")
    myNameSpace.Logon "LatestProfile", , True, True
End Sub