Freigeben über


NameSpace.Logon Method

Outlook Developer Reference

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

Syntax

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

expression   A variable that represents a NameSpace object.

Parameters

Name Required/Optional Data Type Description
Profile Optional Variant The MAPI profile name, as a String, to use for the session.
Password Optional Variant The 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.
ShowDialog Optional Variant True to display the MAPI logon dialog box to allow the user to select a MAPI profile.
NewSession Optional Variant True 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.

Example

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

See Also