Logon Method

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

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

*expression   * An expression that returns a NameSpace object.

*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.


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.

Sub StartOutlook()
 Dim myOlApp As Outlook.Application
 Dim myNameSpace As Outlook.NameSpace
 Set myOlApp = CreateObject("Outlook.Application")
 Set myNameSpace = myOlApp.GetNamespace("MAPI")
 myNameSpace.Logon "LatestProfile", , True, True
End Sub

Applies to | NameSpace Object

See Also | Logoff Method