Initializes a new instance of the Message class with an empty body.
[Visual Basic] Overloads Public Sub New() [C#] public Message(); [C++] public: Message(); [JScript] public function Message();
Use this overload to instantiate an empty Message object.
Specify a Body before sending the Message object. The Body can be any serializable object, such as a text string, structure object, class instance, or embedded object.
The DefaultPropertiesToSend for a MessageQueue are overridden for any Message object that is sent to that queue. (These settings still apply to other objects sent to a queue using Send.)
Set the Formatter before sending the Message to a queue. If you want the body to be human-readable between the time that it is sent and received or peeked, use the SoapMessageFormatter. For messages with dataset bodies, use the DataSetMessageFormatter. The ActiveXMessageFormatter and BinaryMessageFormatter serialize the data into binary representation. The settings require the same formatter at both ends of the message processing. Binary formats are faster than XML format, but not human-readable during transit, and can't be read and fixed if a message becomes corrupted.
When a Message is created, the following read/write properties are set to initial values.
Property | Initial Value |
---|---|
AcknowledgeType | AcknowledgeType.None |
AdministrationQueue | a null reference (in Visual Basic Nothing) |
AppSpecific | 0 |
AttachSenderId | true |
AuthenticationProviderName | Microsoft Base Cryptographic Provider, Ver. 1.0 |
AuthenticationProviderType | CryptoProviderType.RSA_FULL |
Body | a null reference (Nothing) |
BodyStream | Stream.null |
BodyType | 0 |
ConnectorType | Guid.Empty |
CorrelationId | "" (empty string) |
DestinationSymmetricKey | A zero-length array of bytes |
DigitalSignature | A zero-length array of bytes |
EncryptionAlgorithm | EncryptionAlgorithm.RC2 |
Extension | a zero-length array of bytes |
Formatter | SoapMessageFormatter |
HashAlgorithm | HashAlgorithm.MD5 |
Label | "" (empty string) |
Priority | MessagePriority.Normal |
Recoverable | false |
ResponseQueue | a null reference (Nothing) |
SenderCertificate | a zero-length array of bytes |
TimeToBeReceived | Message.InfiniteTimeout |
TimeToReachQueue | Message.InfiniteTimeout |
TransactionStatusQueue | a null reference (Nothing) |
UseAuthentication | false |
UseDeadLetterQueue | false |
UseEncryption | false |
UseJournalQueue | false |
UseTracing | false |
You can change the value for any of these properties through a separate call to the property.
The following example creates an empty message. The example populates the Message with a string Body, and then sends the message to a queue. It assumes there is a queue on the computer "myComputer" with the name "myQueue".
Import the System.Messaging namespace for this example.
[Visual Basic]
Private Sub CreateMessage() 'Declare a message and message queue Dim msg As Message Dim mq As MessageQueue 'Instantiate an empty message object msg = New Message 'Instantiate a new MessageQueue object mq = New MessageQueue("myComputer\myQueue") 'Set message information. msg.Body = "New Message Body" 'Send the message to the queue. mq.Send(msg) End Sub
Message Class | Message Members | System.Messaging Namespace | Message Constructor Overload List | AcknowledgeType | CryptoProviderType | EncryptionAlgorithm | HashAlgorithm | MessagePriority | SoapMessageFormatter | InfiniteTimeout | Guid | Stream | Body | Send | Peek | Receive