<% If Request("DontFrame")<>1 Then Response.Redirect "/iissamples/sdk/asp/docs/SampFram.asp?ovfile=/iishelp/iis/htm/sdk/samp6ftx.asp&srcfile=Queuing/EncryptedDelivery" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
MSMQ allows you to specify that certain messages should be transmitted to a message queue in an encrypted form. This sample demonstrates how you can open a message queue and transmit a private message. </p>
<p>
This example first creates an instance of the <b>MSMQQueueInfo</b> object, which will be used as a template for the actual queue object instances. <b>MSMQQueueInfo</b> contains a number of properties that can be used to configure the queue instances it will create, but in this sample, only the <b>PathName</b> property is set. <b>PathName</b> specifies the MSMQ pathname of the queue, and is given in the general form <i>MachineName\QueueName</i>. Note that in this example, the <i>MachineName</i> part of the MSMQ pathname is a period (.), which indicates that the queue is located on the local computer.</p>
<p>
The <b>MSMQQueueInfo.Open</b> method is used to create an instance of the actual queue object, <b>MSMQQueue</b>, and the variable <i>Queue</i> is set to refer to the new queue instance. </p>
<p>
At this point, having gained access to the IIS_SDK_EXAMPLE queue, this sample now creates a message by instantiating <b>MSMQMessage</b>. The reference to the instance, <i>Msg</i>, is used to set the description and content of the message using the <b>Label</b> and <b>Body</b> properties. This sample then sets the <b>PrivLevel</b> property to indicate that the message is private and should be encrypted. If the <b>PrivLevel</b> property is not set, then the message should be considered non-private.</p>
<p>
With the message complete and the queue configured, the script is ready to send the message. The <b>MSMQMessage.Send</b> method is called to send the message to the queue pointed to by the reference <i>Queue</i>, and the queue is closed with the <b>Close</b> method. The message is now available to any other applications that have permission and inclination to access that queue. </p>
<p>
<b>Note</b> This sample requires that you install MSMQ on your host machine. It also requires, prior to running this sample for the first time, that you start MSMQ Explorer and create a new queue named IIS_SDK_EXAMPLE. MSMQ Explorer can also be used after the sample is run so that you can examine the results of the script's execution.</p>