Platform SDK: MAPI

Adding or Deleting Providers in a Message Service

To add or delete service providers in a message service, use the IProviderAdmin interface. You can retrieve an IProviderAdmin pointer by calling IMsgServiceAdmin::AdminProviders. The provider table, accessable through IProviderAdmin::GetProviderTable, lists information about the service providers currently installed in the message service. Clients and service providers can use the provider table to access the name of the provider DLL file, for example, or the MAPIUID, display name, and type of the provider as well as information about the message service. See Provider Table for more information.

To add or delete a service provider in a message service

  1. Call the AdminServices method to access a message service administration object.
  2. Call IMsgServiceAdmin::GetMsgServiceTable to access the message service table.
  3. Build a property restriction using an SPropertyRestriction structure that matches PR_DISPLAY_NAME or PR_SERVICE_NAME with the name of the message service to be modified.
  4. Call the message service table's IMAPITable::FindRow method to locate the row in the table that represents the targeted message service.
  5. Call IMsgServiceAdmin::AdminProviders to retrieve an IProviderAdmin pointer. Pass the PR_SERVICE_UID column from the message service table row as the lpUID parameter.
  6. Call IProviderAdmin::GetProviderTable to access the provider table.
  7. Build a property restriction using an SPropertyRestriction structure that matches PR_DISPLAY_NAME or PR_PROVIDER_DISPLAY with the name of the service provider to be added or deleted.
  8. Call the provider table's IMAPITable::FindRow method to locate the row in the table that represents the targeted service provider.
  9. Call IProviderAdmin::CreateProvider to add the provider or IProviderAdmin::DeleteProvider to remove it from the message service. For CreateProvider, pass the provider's PR_DISPLAY_NAME property as the lpszProvider parameter. For either method, pass the provider's PR_SERVICE_UID property as the lpUID parameter. After the service provider has been added or deleted, the change will not be apparent until a new session is created.

Another technique for adding a service provider, specifically a message store provider, to a profile involves constructing an entry identifier for the provider. Because constructing an entry identifier requires knowledge of its format, this technique can only be used if the service provider has made its entry identifier format public.

With the newly constructed entry identifier, a client can call IMAPISession::OpenMsgStore. MAPI automatically creates a profile section in the profile for the service provider, but does not add it to a message service.

Some message services do not allow this type of dynamic modification; whether or not it is supported is up to the message service. Another feature that may or may not be supported is the ability to directly access a message service's private profile sections. If the message service you are using permits such access, it will publish the GUID that represents the private section in MAPISVC.INF. You can pass this GUID in a call to IProviderAdmin::OpenProfileSection to access the profile section.