Platform SDK: MAPI

Creating and Configuring a Profile

See Message Services and Profiles for more information about creating a profile using MAPI, adding message services to it and configuring them, and establishing certain default settings in the profile.

Design Tasks

  1. Understand what message services your profile requires, and whether you wish to give your user any choice of services.
  2. Choose your tool. There are several tools available for creating profiles. Alternatives include:
  3. Understand in what order to add services. Following are guidelines for ordering service providers. These guidelines will occasionally conflict; when they do, you will have to write C or C++ code to configure one or more of the provider orders. You can use the Delivery and Addressing pages of the Mail and Fax control panel applet to inspect a profile you have created and see if the providers have been ordered as you expected.

If your application must run unattended, perhaps as a background application or a Windows NT service, some special cautions apply. See Writing an Automated Client and Windows NT Service Client Applications.

If your application requires a specific profile other than the default profile, you must save its name in your own configuration database or use a specific naming convention. MAPI does not expose any profile attributes other than the name and default flag in the profile table, and the default profile flag is reserved for the messaging client and related IPM applications.

Implementation Tasks

To create a .PRF file for use with the NEWPROF.EXE utility

  1. Assemble information from existing .PRF files. For each service you plan to use, copy the section that lists the name, type, and property identifier for each configuration property. The section must have the same name as the service. Services implemented by Microsoft are listed in Section 4 of the DEFAULT.PRF file that is installed with MAPI.
  2. Place the profile name in the ProfileName= line of the [General] section.
  3. Create the [Service List] section, in Section 2 of the file. In this section, list each service you require and the name of the section that contains its configuration properties. Refer to the earlier guidelines to establish the order of services.
  4. For each service listed in the [Service List] section, create a section that lists the value for each configuration property; the section must have the same name as the service. This information appears in Section 3 of the file.
  5. Invoke the utility. On 32-bit operating systems, it can be run from a command line or batch file. On 16-bit Windows, NEWPROF.EXE cannot be run from an MS-DOS shell; it can be run by a Windows-based setup script, by the Run command on the File menu in Program Manager or File Manager, or by the WinExec system call. It takes command line parameters as follows:

Note  References to Sections 1, 2, 3, and 4 in the preceding procedure refer to comments in the DEFAULT.PRF file distributed with the Platform SDK.

To write custom C or C++ code to create a profile

  1. Read the header file for each service. Understand what properties you need to configure and what values you will use.
  2. Call the MAPIAdminProfiles function to obtain an IProfAdmin interface. Call the CreateProfile method to create your profile, and the AdminServices method to obtain an IMsgServiceAdmin interface.
  3. Add message services to the profile. Refer to the previous guidelines for the order you should use. For each service, use the IMsgServiceAdmin interface to:
    a.    Call the CreateMsgService method.

    b.    Obtain the MAPIUID structure of the service you just created.

    1.    Call the GetMsgServiceTable method to obtain an IMAPITable interface.

    2.    Call the HrQueryAllRows function to retrieve all rows from the table.

    3.    Get the PR_SERVICE_UID column from the last row. This is the MAPIUID structure of the last service added. You may wish to check with an assertion that other properties of the service are as you expect.

    c.    Call the ConfigureMsgService method, passing the MAPIUID structure of the service you just created and a property value array with its configuration properties.


  1. If you must make configuration calls that require an IMAPISession interface, such as IMAPISession::SetDefaultStore, IAddrBook::SetPAB, or IAddrBook::SetABSearchPath, pass the MAPI_NO_MAIL flag to the MAPILogonEx function.
  2. To make your profile temporary, call the IProfAdmin::DeleteProfile method immediately after logging on to the profile. It will be deleted after you log off, and will not be visible to other applications in the meantime.

About Sample Source Code

None available at this time.