Initializing a Simple MAPI Client

Before starting a Simple MAPI messaging session you need to initialize your client application. This involves checking the computer's WIN.INI file to determine if Simple MAPI is available, loading the correct dynamic link library (DLL) that contains the Simple MAPI functions, and setting a pointer to each function.

    To initialize your client
  1. Determine that Simple MAPI is available by checking the [MAIL] section in the computer's WIN.INI file for the MAPI entry. This entry will have a value of 1 if Simple MAPI is installed, or 0 if uninstalled.
  2. Load the correct DLL for your operating system by calling the Windows LoadLibrary function as follows:
    hlibMAPI = LoadLibrary("MAPI.DLL");    // 16 bit clients
    hlibMAPI = LoadLibrary("MAPI32.DLL");  // 32 bit clients
     

    The two DLLs for Simple MAPI are MAPI.DLL for 16-bit clients and MAPI32.DLL for 32-bit clients.

  3. Set the pointer variable to the actual address of the MAPILogon function as follows:
    lpfnMAPILogon = (LPFNMAPILOGON) GetProcAddress 
        (hlibMAPI, "MAPILogon")))
     

Similarly defined constants exist for the other Simple MAPI functions, so you simply need to set the value of the function pointers using the Win32 function GetProcAddress as in the previous example.