This example retrieves an MSMQ message from the Outgoing Service queue. This example requires references to the System.Messaging and System.XML assemblies.
Notice how the example performs the following steps:
Private Sub GetMessage() 'Create queue object to retrieve messages from the default outgoing queue Dim MyQueue As New MessageQueue(".\private$\econnect_outgoing9") 'Create an MSMQ formatter and transaction objects MyQueue.Formatter = New ActiveXMessageFormatter Dim MyTransaction As New MessageQueueTransaction 'Create a message object Dim MyMessage As Message Try 'Retrieve a message from the queue 'This example assumes there is always a message waiting in the queue MyTransaction.Begin() MyMessage = MyQueue.Receive(MyTransaction) MyTransaction.Commit() 'Retrieve the string from the message Dim MyDocument As [String] = CType(MyMessage.Body, [String]) 'Load the string into an XML document object Dim MyXml As New XmlDocument MyXml.LoadXml(MyDocument) 'Display the XML from the queue message MessageText.Text = MyXml.InnerXml Catch err As SystemException ErrorText.Text = err.InnerException.ToString() End Try End Sub