Starting a Simple MAPI Session

Most MAPI calls are made in the context of a session, defined as an active connection between a client application and the MAPI subsystem. Each session uses a particular profile that specifies the set of available message services and the providers to manage those services. Before your client application can send or receive messages, it needs to log on and establish a session.

There are two types of sessions, temporary and persistent. A temporary session exists only for the lifetime of a single Simple MAPI call. A persistent session exists until the session is explicitly closed. Establishing a temporary session is referred to as implicit logon; establishing a persistent session is called explicit logon. You can use a persistent session for all calls that require the same set of providers and a temporary session for single calls that do not require the same context.

Note Some messaging systems can allow a limited number of sessions, so you must be able to handle a MAPI_E_TOO_MANY_SESSIONS return value. This value can be returned when a user is logged on to the system through an e-mail application and a mail-enabled application attempts to log on with a different identity.