Requesting a Logon User Interface with Simple MAPI

A client application can log on either by displaying a logon dialog box to provide user interaction or by providing necessary credentials (profile name and password if necessary) programmatically. If you require user interaction, you can use the common dialog box provided by Simple MAPI or create your own. However, it is recommended that you use the standard MAPI dialog boxes whenever possible to promote a consistent look and ease of use.

The presence or absence of the MAPI_LOGON_UI value in the flFlags parameter of the MAPILogon function controls the logon dialog box display.

    To force the dialog box to be displayed

Set MAPI_LOGON_UI in the flFlags parameter and set the lpszProfileName and lpszPassword parameters to NULL as follows:

flFlags |= MAPI_LOGON_UI;
MAPILogon ((ULONG) hWnd, NULL, NULL, flFlags, 0, &lhSession);
 

If you provide a value for lpszProfileName (and lpszPassword if necessary), MAPILogon attempts to establish a session without a user interface. Only if this attempt fails will MAPILogon display the logon dialog box for the user to enter new credentials.