MAPI objects are implemented using C++ classes or C data structures, depending on the language and the API set a client or service provider is using. Service providers are written in C or C++ with the MAPI service provider interface; client applications can use any of the three supported languages and the four supported client interfaces. If possible, clients and service providers using the object-oriented programming interface should use C++.
C++ is the preferred choice because MAPI is an object oriented technology and C++ lends itself more readily to object oriented development. The resulting code is simpler and more straightforward making it easier to maintain. Also, the MAPI documentation is written primarily for C++ developers; all of the syntax descriptions for the MAPI interface methods in the MAPI Programmer's Reference are in C++.
When a MAPI object is implemented, a client or service provider creates code for all of the interface methods, code for any private methods that are specific to the implementation, and code to support private data members for maintaining state information. The code for the interface methods must follow the specifications published by MAPI that document expected behavior.
There are many macros in the MAPIDEFS.H header file and OLE header files that clients and service providers in either language can use to help them with their definitions of MAPI objects. For example, there is a macro to define the methods of each of the MAPI interfaces. The macro to define the methods of IUnknown appears in MAPIDEFS.H as follows:
#define MAPI_IUNKNOWN_METHODS(IPURE) \
MAPIMETHOD(QueryInterface) \
(THIS_ REFIID riid, LPVOID FAR * ppvObj) IPURE; \
MAPIMETHOD_(ULONG,AddRef) (THIS) IPURE; \
MAPIMETHOD_(ULONG,Release) (THIS) IPURE; \