MessageQueue
class has a
GetAllMessages()
which returns an array of
Message
instances.
Once you get this array, initialize a counter variable to zero. Then loop through all messages in the array, and use the
BodyStream
property of the
Message
instance to get a reference to the underlying stream. Finally, use the
Length
property of the stream to get its length (in bytes), and add it to the counter.
Message[] messages = queue.GetAllMessages();
long total = 0;
foreach (Message message in messages)
{
total += message?.BodyStream?.Length;
}