Optional. The Label property specifies a description of the queue or message.
Type: | String |
Run time: | read/write |
object.Label
Syntax Element | Description |
object | Either the queue information (MSMQQueueInfo) object that defines the queue, or the message (MSMQMessage) object that defines the message. |
To specify the label of a queue, set Label and call the MSMQQueueInfo object's Create method.
To reset the label of a queue after the queue is created, set Label to a new label and, if the queue is open, call the MSMQQueueInfo object's Update method. If the queue is not open do not call Update, the queue's properties are updated automatically when the queue is opened.
To find the label of a queue, call the MSMQQueueInfo object's Refresh method.
For an example of how MSMQ sends the messages to a queue, see Sending Messages To a Queue.
This example creates a private queue on the local machine, setting the queue's label to "Test 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 Private Sub Form_Click() Set qinfo = New MSMQQueueInfo qinfo.PathName = ".\PRIVATE$\myqueue" qinfo.Label = "Test Queue" qinfo.Create MsgBox "Queue's Format name is: " + qinfo.FormatName End Sub
This example creates a queue, opens the queue for sending messages, sets the label 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 (no error ' handling if queue exists. '************************** Set qinfo = New MSMQQueueInfo qinfo.PathName = ".\LabelTest" 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
Body, Close, Create, FormatName, MSMQMessage, MSMQQueue, MSMQQueueInfo, Open, PathName