Releasing the Transport Provider

    When MAPI or the MAPI spooler finishes using a transport logon object
  1. MAPI or the MAPI spooler calls the transport provider's IXPLogon::TransportLogoff method.
  2. The transport provider invalidates the status object by calling the IMAPISupport::MakeInvalid method. Whether the transport provider invalidates message objects that are being sent or received at the time of the TransportLogoff call depends on the flags that were passed to TransportLogoff.
  3. The transport provider calls the support object's Release method to remove the provider's row from the status table and remove from internal tables any Unique Identifiers (UIDs) that were set with the IMAPISupport::SetProviderUID method. It decrements the count of known logon objects active on this provider object. If the count reaches zero, MAPI calls the IXPProvider::Shutdown method and Release on the provider object. If this was the last known provider object using this DLL on this process, MAPI calls FreeLibrary on the DLL at some later time. Memory for the MAPI support object is freed and the support object Release method returns.
  4. The TransportLogoff method returns S_OK.
  5. MAPI or the MAPI spooler calls Release on the transport provider's logon object. The memory for the object is discarded.
  6. MAPI or the MAPI spooler calls FreeLibrary on the provider DLL.

For robustness, the logon and provider objects should be able to handle final Release calls on themselves without first having their TransportLogoff or Shutdown methods called. If Release is called in such cases, transport providers should treat the calls as if TransportLogoff or Shutdown had been called with a zero argument followed by Release.