Setting Up a Transport Provider

Setting Up a Transport Provider

Before you set up a transport provider, you must initialize the transport provider, and MAPI must log on to the transport provider. For more information, see Initializing a Transport Provider.

Once you have initialized the transport provider, you must implement the IXPLogon::AddressTypes function in order for MAPI to determine what types of e-mail addresses the transport provider supports. When the transport provider is ready to send and receive messages, it calls the IXPLogon::TransportNotify function to enable message transmission.

In this topic, these functions are demonstrated by using code examples from the MRXP Sample Transport Provider. The MRXP Sample Transport Provider implements a shared network file system transport provider using a UNC share or a local folder. For more information about downloading and installing the MRXP Sample Transport Provider, see Installing the Sample Transport Provider.

After you initialize and set up a transport provider, you are ready to send and receive messages by using the transport provider. For more information, see Sending Messages by Using a Transport Providerand Receiving Messages by Using a Transport Provider.

Address Types Routine

The IXPLogon::AddressTypes function returns a list of unique identifiers (UIDs) and e-mail address types that it accepts. In the following example, the UID parameter, lpppUIDArray, is set to NULL. The accepted e-mail address type is set to MRXP_ADDRTYPE and is returned through the lpppAdrTypeArray parameter.

Bb820974.vs_note(en-us,office.12).gif  Note
The MRXP_ADDRTYPE value is defined in the mrxp.h header file as follows: #define MRXP_ADDRTYPE _T("MRXP").

CXPLogon::AddressTypes() Example

  STDMETHODIMP CXPLogon::AddressTypes(
    ULONG FAR* lpulFlags,
    ULONG FAR * lpcAdrType,
    LPTSTR FAR * FAR * lpppAdrTypeArray,
    ULONG FAR * lpcMAPIUID,
    LPMAPIUID FAR * FAR * lpppUIDArray)
{
    Log(true, _T("CXPLogon::AddressTypes function called\n"));
if (!lpulFlags || !lpcAdrType || !lpppAdrTypeArray || !lpcMAPIUID || !lpppUIDArray)
    return MAPI_E_INVALID_PARAMETER;

HRESULT hRes = S_OK;
static LPTSTR lpszAddrType = MRXP_ADDRTYPE;

*lpulFlags = fMapiUnicode;
*lpcMAPIUID = 0;
*lpppUIDArray = NULL;

*lpcAdrType = 1;
*lpppAdrTypeArray = &lpszAddrType;

return hRes;

}

Notification Routine

The IXPLogon::TransportNotify function enables message transmission and reception. The lpulFlags parameter is evaluated and the appropriate status flags are added or removed. In the following example, the NOTIFY_ABORT_DEFERRED and NOTIFY_CANCEL_MESSAGE flags are ignored.

CXPLogon::TransportNotify() Example

  STDMETHODIMP CXPLogon::TransportNotify(
    ULONG FAR * lpulFlags,
    LPVOID FAR * /*lppvData*/)
{
    Log(true, _T("CXPLogon::TransportNotify function called\n"));
    if (!lpulFlags)
        return MAPI_E_INVALID_PARAMETER;
    HRESULT hRes = S_OK;
EnterCriticalSection(m_pProvider->GetCS());

if (*lpulFlags & NOTIFY_BEGIN_INBOUND)
{
    Log(true, _T("CXPLogon::TransportNotify received NOTIFY_BEGIN_INBOUND\n"));
    AddStatusBits(STATUS_INBOUND_ENABLED);
}
if (*lpulFlags & NOTIFY_END_INBOUND)
{
    Log(true, _T("CXPLogon::TransportNotify received NOTIFY_END_INBOUND\n"));
    RemoveStatusBits(STATUS_INBOUND_ENABLED);
}
if (*lpulFlags & NOTIFY_END_INBOUND_FLUSH)
{
    Log(true, _T("CXPLogon::TransportNotify received " +
        "NOTIFY_END_INBOUND_FLUSH\n"));
    RemoveStatusBits(STATUS_INBOUND_FLUSH);
}
if (*lpulFlags & NOTIFY_BEGIN_OUTBOUND)
{
    Log(true, _T("CXPLogon::TransportNotify received " +
        "NOTIFY_BEGIN_OUTBOUND\n"));
    AddStatusBits(STATUS_OUTBOUND_ENABLED);
}
if (*lpulFlags & NOTIFY_END_OUTBOUND)
{
    Log(true, _T("CXPLogon::TransportNotify received NOTIFY_END_OUTBOUND\n"));
    RemoveStatusBits(STATUS_OUTBOUND_ENABLED);
}
if (*lpulFlags & NOTIFY_END_OUTBOUND_FLUSH)
{
    Log(true, _T("CXPLogon::TransportNotify received " +
        "NOTIFY_END_OUTBOUND_FLUSH\n"));
    RemoveStatusBits(STATUS_OUTBOUND_FLUSH);
}
if (*lpulFlags & NOTIFY_ABORT_DEFERRED)
{
    // We're just going to ignore NOTIFY_ABORT_DEFERRED for now.
    Log(true, _T("CXPLogon::TransportNotify received " +
        "NOTIFY_ABORT_DEFERRED\n"));
}
if (*lpulFlags & NOTIFY_CANCEL_MESSAGE)
{
    // We're just going to ignore NOTIFY_CANCEL_MESSAGE for now.
    Log(true, _T("CXPLogon::TransportNotify received " +
        "NOTIFY_CANCEL_MESSAGE\n"));
}

hRes = UpdateStatusRow();
if (FAILED(hRes))
    Log(true, _T("CXPLogon::TransportNotify: UpdateStatusRow returned an error: "
        + "0x%08X\n"), hRes);

LeaveCriticalSection(m_pProvider->GetCS());

return hRes;

}

See Also

About the Sample Transport Provider

Installing the Sample Transport Provider

Initializing a Transport Provider

Sending Messages by Using a Transport Provider

Receiving Messages by Using a Transport Provider

Shutting Down a Transport Provider