Body
MSMQMessage

The Body property specifies the contents of the message.

Quick Info

Type: Variant
Run time: read/write

Syntax

object.Body
 
Syntax Element Description
object Message (MSMQMessage) object that defines message.

Settings

Any simple Variant type: string, array of bytes, numeric type, currency, date, or persistent ActiveX object.

Remarks

The sending application does not indicate the type of information (string, array of bytes, numeric types, currency, date, or ActiveX object) that is stored in the message body. MSMQ determines the body type from the true type of the Variant assigned to the Body property.

The receiving application, however, should determine what type of information is in the message body. To do this, it can inspect the message body using a standard Visual Basic If..Then..Else function with the following conditional functions: TypeOf and TypeName. The TypeName function can be used to find out if the message in the queue is a string, array of bytes, numeric type, currency, or date. If it is not one of these, TypeOf can be used to see which OLE interface the object supports. For an example on how MSMQ reads messages from a queue, see Reading Messages in a Queue.

For information on the type of objects that can be sent, see MSMQ ActiveX Support.

For an example of how MSMQ sends the messages to a queue, see Sending Messages to a Queue.

Example

This example creates a queue, opens the queue for sending messages, sets the body of a message, then sends the message to the queue.

To try this example using Microsoft® Visual Basic® (version 5.0), paste the code into the Code window of a form, and then run the example and click the form.

Dim qinfo As MSMQQueueInfo
Dim q As MSMQQueue
Dim msg As New MSMQMessage

Private Sub Form_Click()
   '**************
   ' Create queue.
   '**************
  Set qinfo = New MSMQQueueInfo
  qinfo.PathName = ".\SendTest"
  qinfo.Label = "Test Queue"
  qinfo.Create
   '**************
   ' Open queue.
   '**************
  Set q = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
   '**************
   ' Send Message.
   '**************
  msg.Label = "Test Message"
  msg.Body = "This is a test message with a string Body."
  msg.Send q
 
 
 q.Close

End Sub
 

See Also

Close, Create, FormatName, Label, MSMQMessage, MSMQQueue, MSMQQueueInfo, Open, PathName, Send


© 1997 by Microsoft Corporation. All rights reserved.