PROPID_M_BODY
A version of this page is also available for
4/8/2010
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.
The sending and receiving applications are responsible to understand the type of information in the body.
For example, if the sending application sends a binary file with an internal structure, the receiving application is responsible to know how to decipher what was sent.
You can use the PROPID_M_BODY_TYPE property to indicate what type of information is in the message body.
It is recommended that the sending application set PROPID_M_BODY_TYPE when 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.
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, which indicates a serialized object that supports IPersistStream and IPersistStorage
- VT_STORED_OBJECT, which indicates a serialized object that supports IPersistStream and IPersistStorage
Many persistent objects, such as all Microsoft Office documents, can be sent as MSMQ messages.
Some programming tools, such as Microsoft® Visual Basic® 6.0, can create user-defined objects that support the IPersistStream or IPersistStorage interface.
When you pass fixed-size messages between the sending and receiving application and fixed-size messages are the only type of message passed, you can allocate a fixed-size buffer for receiving the message body without caring about 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++;
Note
OS versions prior to 2.12 require the MSMQ add-on pack.
Requirements
Header | mq.h |
Windows Embedded CE | Windows CE 2.0 and later |
Windows Mobile | Windows Mobile Version 5.0 and later |
See Also
Reference
MQReceiveMessage
MQSendMessage
PROPID_M_BODY_SIZE
PROPID_M_BODY_TYPE
MQMSGPROPS