Are you receiving an error or is it just not working? Your application
needs write permission to the queue to put a message on it. The
MessageData object in the code below is a simple object in our system.
private void QueueMessage(MessageData msgData)
{
log.Debug("Adding new message to the queue");
System.Messaging.MessageQueue queue = new
System.Messaging.MessageQueue();
System.Messaging.BinaryMessageFormatter formatter = new
System.Messaging.BinaryMessageFormatter
(System.Runtime.Serialization.Formatters.FormatterAssemblyStyle.Full,
System.Runtime.Serialization.Formatters.FormatterTypeStyle.TypesAlways);
//Set the default properties for the queue
queue.Formatter = formatter;
queue.Path = ".\\private$\\queuename";
//Using Microsoft's javascript serializer
JavaScriptSerializer serializer = new JavaScriptSerializer
();
queue.Send(serializer.Serialize(msgData));
}