PROPID_M_BODY

This property contains the body of the message.

  • Type Indicator
    VT_VECTOR | VT_UI1
  • PROPVARIANT Field
    caub
  • Property Values
    Body of the message.

Remarks

The body of a message can consist of any type of information. It is the responsibility of the sending and receiving applications to understand the type of information that is in the body. For example, the sending application could send a binary file with any internal structure, and it would be the responsibility of the receiving application to know how to decipher what was sent. The PROPID_M_BODY_TYPE property can be used to indicate what type of information is included in the message body.

It is recommended that the sending application set PROPID_M_BODY_TYPE whenever sending messages. If PROPID_M_BODY_TYPE is not set, the application reading the message should assume the message is an array of bytes. The MSMQ COM implementation does this automatically.

Each MSMQ message can have no more than 4 MB of data.

To set the body of a message, specify PROPID_M_BODY and PROPID_M_BODY_TYPE in the MQMSGPROPS structure and call MQSendMessage.

To retrieve the message body from a message, specify PROPID_M_BODY_SIZE and PROPID_M_BODY in the MQMSGPROPS structure. Then, call MQReceiveMessage and examine the returned value.

Before using the returned value of PROPID_M_BODY, always inspect the returned value of PROPID_M_BODY_SIZE to see if a message body was sent with the message. A returned value of 0 indicates that no body was attached to the message. A nonzero returned value indicates that the body of the message was returned by PROPID_M_BODY.

The MSMQ COM implementation supports the following specific types: VT_I2, VT_UI2, VT_I4, VT_UI4, VT_R4, VT_R8, VT_CY, VT_DATE, VT_BOOL, VT_I1, VT_UI1, VT_BSTR, VT_ARRAY, VT_STREAMED_OBJECT, and VT_STORED_OBJECT, where the last two indicate serialized objects that support IPersistStream and lPersistStorage.

There are many persistent objects, such as all Microsoft® Office documents, that can be sent as MSMQ messages. Also note that some programming tools, such as Microsoft® Visual Basic® 6.0, can create user-defined objects that support the IPersistStream or IPersistStorage interface.

When passing fixed-size messages between the sending and receiving application, and if this is the only type of message passed, you can allocate a fixed size buffer for receiving the message body without caring about the body size.

Examples

The following examples show how PROPID_M_BODY is specified in the MQMSGPROPS structure when setting and retrieving the message body.

To send the message body

WCHAR wszMessageBody[] = L"Test Message.";
MsgProps.aPropID[i] = PROPID_M_BODY;                 // Property ID
MsgProps.aPropVar[i].vt = VT_VECTOR|VT_UI1;          // Type indicator
MsgProps.aPropVar[i].caub.pElems = (LPBYTE)wszMessageBody;
MsgProps.aPropVar[i].caub.cElems = sizeof(wszMessageBody);
i++

MsgProps.aPropID[i] = PROPID_M_BODY_TYPE;            // Property ID
MsgProps.aPropVar[i].vt = VT_UI4;                    // Type indicator
MsgProps.aPropVar[i].ulVal = dwBodyType;
i++

To retrieve the message body

MsgProps.aPropID[i] = PROPID_M_BODY_SIZE;            // Property ID
MsgProps.aPropVar[i].vt = VT_UI4;                    // Type indicator
i++

DWORD dwBodyBufferSize = 1024;
UCHAR *pucBodyBuffer = (UCHAR *)malloc(dwBodyBufferSize);
MsgProps.aPropID[i] = PROPID_M_BODY;                 // Property ID
MsgProps.aPropVar[i].vt = VT_VECTOR|VT_UI1;          // Type indicator
MsgProps.aPropVar[i].caub.pElems = (UCHAR*)pucBodyBuffer;
MsgProps.aPropVar[i].caub.cElems = dwBodyBufferSize;
i++

Requirements

Runs on Versions Defined in Include Link to
Windows CE OS 2.0 and later. Versions prior to 2.12 require the MSMQ add-on pack. Mq.h    

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

MQReceiveMessage, MQSendMessage, lPersistStorage, PROPID_M_BODY_SIZE, PROPID_M_BODY_TYPE, MQMSGPROPS

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.