Gets or sets the information in the body of the message.
[Visual Basic] Overridable Public Property BodyStream As Stream [C#] public Stream BodyStream {virtual get; virtual set;} [C++] public: __property virtual Stream* get_BodyStream(); public: __property virtual void set_BodyStream(Stream*); [JScript] public function get BodyStream() : Stream; public function set BodyStream(Stream);
Represents the serialized information included in the Body of the message.
Exception Type | Condition |
---|---|
InvalidOperationException | The message queue is filtered not to read the Body property. |
The body of a message can consist of any type of information, including string, date, currency, number, an array of bytes, or any persistent COM object.
To read or write the message body, use the Body property. The BodyStream represents the body content after it has been serialized using the formatter specified in the Formatter property.
The following example peeks the queue "myQueue" on the computer "myComputer". It retrieves the body of the message as a stream and displays it as output.
Import the System.Messaging namespace for this example.
[Visual Basic]
Private Sub PeekMessage() 'Declare a message and message queue. Dim msg As Message Dim mq As MessageQueue 'Set the MessageQueue to the queue above, myQueue. mq = New MessageQueue("myComputer\myQueue") 'Peek the first message in the queue. msg = mq.Peek 'Show the contents of the body. Console.WriteLine(msg.BodyStream.ToString) End Sub
Message Class | Message Members | System.Messaging Namespace | Message | Body | BodyType | Formatter | AppSpecific | Extension | UseEncryption | Send | TBD