Send Feedback

The CHANGE_PROP_TYPE macro updates the property type of a property tag to a specified value. The property identifier is unchanged.


CHANGE_PROP_TYPE (ulPropTag, ulPropType)


  • ulPropTag
    The property tag to be modified.
  • ulPropType
    The new value for the property type.

Code Example

The following code example demonstrates how using CHANGE_PROP_TYPE allows you to send UNICODE characters in SMS messages.

Note   To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them.

    SPropValue  rgprops[8]      = {0};
    ULONG       cProps          = 0;
    LPSTREAM    pstm            = NULL;
    TCHAR       szwSubject[500] = SUBJECT_LINE;
    HRESULT     hr;

    // Setup recipients.
    hr = CEMAPI_SetMessageRecipients(pmsg);

    // Set the flags and a subject.
    rgprops[cProps].ulPropTag = PR_MESSAGE_CLASS;
    rgprops[cProps].Value.lpszW = L"IPM.SMStext.Msg";

    GUID guid;
    guid.Data1 = 0x00020328; // PS_MAPI
    guid.Data2 = 0;
    guid.Data3 = 0;
    guid.Data4[0] = 0xC0;
    guid.Data4[1] = 0x0;
    guid.Data4[2] = 0x0;
    guid.Data4[3] = 0x0;
    guid.Data4[4] = 0x0;
    guid.Data4[6] = 0x0;
    guid.Data4[6] = 0x0;
    guid.Data4[7] = 0x46;

    MAPINAMEID NamedMsgProps[1] = {0};

    NamedMsgProps[0].lpguid  = &guid;
    NamedMsgProps[0].ulKind  = MNID_STRING; 
    NamedMsgProps[0].Kind.lpwstrName = const_cast<LPWSTR>(L"SMS:Unicode");

    MAPINAMEID* pNames = NamedMsgProps;
    LPSPropTagArray lppPropTags = NULL;

    HRESULT hrp = pmsg->GetIDsFromNames(ARRAYSIZEOF(NamedMsgProps), &pNames, MAPI_CREATE, &lppPropTags);

    if((hrp == S_OK) || (hrp == MAPI_W_ERRORS_RETURNED) ) //MAPI_W_ERRORS_RETURNED;
        MessageBox(NULL,L"Success", L"GetIDsFromNames",MB_OK);
        ULONG *pulPropTag = lppPropTags[0].aulPropTag;
        // The return values from GetIDsFromNames are property IDs that do not yet have a type associated with them.
        // The type informatio must be added to get the final tag.
        rgprops[cProps].ulPropTag = CHANGE_PROP_TYPE(*pulPropTag, PT_BOOLEAN);
        rgprops[cProps].Value.b = true;

        MessageBox(NULL,L"Failure", L"GetIDsFromNames",MB_OK);

    rgprops[cProps].ulPropTag = PR_MSG_STATUS;
    rgprops[cProps].Value.ul = MSGSTATUS_RECTYPE_SMS;

    rgprops[cProps].ulPropTag = PR_MESSAGE_FLAGS;
    rgprops[cProps].Value.ul  = MSGFLAG_UNSENT;  // MSGFLAG_FROMME | MSGFLAG_UNSENT.

    if (szwSubject != NULL)
        rgprops[cProps].ulPropTag   = PR_SUBJECT_W;
        rgprops[cProps].Value.lpszW = szwSubject;

    rgprops[cProps].ulPropTag   = PR_MESSAGE_CLASS;
    rgprops[cProps].Value.lpszW = const_cast<LPTSTR>(L"IPM.SMStext");

    // Apply the property values to this message.
    hr = pmsg->SetProps(cProps,    // count of property
                        rgprops,   // an array of property

    return hr;


Pocket PC: Pocket PC 2002 and later
Smartphone: Smartphone 2002 and later
OS Versions: Windows CE 3.0 and later
Header: mapidefs.h
Library: cemapi.lib

See Also

MAPI Macros | Messaging | SPropValue

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.