Is Simple MAPI simply Unicode?

by Michael S. Kaplan, published on 2007/07/01 23:14 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2007/07/01/3654867.aspx


It is funny. If you look at the documentation for the functions supported by Simple MAPI, they all look something like this one:

ULONG FAR PASCAL MAPIAddress(
  LHANDLE lhSession,
  ULONG ulUIParam,
  LPTSTR lpszCaption,
  ULONG nEditFields,
  LPTSTR lpszLabels,
  ULONG nRecips,
  lpMapiRecipDesc lpRecips,
  FLAGS flFlags,
  ULONG ulReserved,
  LPULONG lpnNewRecips,
  lpMapiRecipDesc FAR * lppNewRecips
  )

The docs, with their LPTSTR parameters, almost seem like they would support Unicode.

However, looks (and docs) can be deceiving.

Looking at mapi.h, the definition is actually:

typedef ULONG (FAR PASCAL MAPIADDRESS)(
    LHANDLE lhSession,
    ULONG_PTR ulUIParam,
    __in LPSTR lpszCaption,
    ULONG nEditFields,
    __in LPSTR lpszLabels,
    ULONG nRecips,
    lpMapiRecipDesc lpRecips,
    FLAGS flFlags,
    ULONG ulReserved,
    LPULONG lpnNewRecips,
    lpMapiRecipDesc FAR *lppNewRecips
);
typedef MAPIADDRESS FAR *LPMAPIADDRESS;
MAPIADDRESS MAPIAddress;

There is no MapiAddressA and MapiAddressW, and if you compile with UNICODE/_UNICODE and were trying to use these functions with Univode strings, then you will create a bunch of compile errors. :-(

The Simple MAPI that is out there does not support Unicode.

Which is kind of a shame since there are a whole lot of languages that you cannot use wuthout it, these days....

Though I suppose we should be happy, at least no one tried to claim that it is supported by MSLU like last time! :-)

 

This post brought to you by(U+1e02, a.k.a. LATIN CAPITAL LETTER B WITH DOT ABOVE)


# Dean Harding on 1 Jul 2007 11:34 PM:

Even the full-blown COM API for MAPI says this (taken from http://msdn2.microsoft.com/en-us/library/ms528625.aspx):

"[...] supports Unicode character strings [...] for Windows NT platforms only. The Unicode strings are converted to the multibyte character string (MBCS) format before they are displayed in the common dialog box."

That documentation is rather confusing (*which* MBCS format? The current codepage?) but it seems to imply that the underlying datastructures are ANSI and the COM API simply converts all Unicode strings to the current ANSI codepage before doing the actual work...

# Michael S. Kaplan on 1 Jul 2007 11:42 PM:

I would tend to blame the actual interface developers for these sorts of things, for poorly describing them to the doc writers....


Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

go to newer or older post, or back to index or month or day