MessageQueue.Purge Method - Purge Contents a Queue

Purges the contents of a queue on a Message Queuing server.

If you are going to use this in an ASPX page you must ensure that the application pool has permissions to perform this function. Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code

MSDN Message Queue Class (Purge)


        Try
            'Connect to a queue on the local computer
            Dim myQueue As New System.Messaging.MessageQueue()
            myQueue.Path = ".\myQueue"
            
            'Delete all messages from the queue.
            myQueue.Purge()

           Response.Write ("Purge Complete!")

        Catch ex As Exception
            Response.Write ("ERROR: " & ex.ToString)
        End Try