Insert message in Message Queue


The following sample code will give you an idea that, how to insert messages in Message Queue.


  • Add reference to System.Messaging
  • Add using System.Messaging;
  • private void InsertMessageinQueue() { try { string qname = @"FormatName:DIRECT=TCP:192.168.1.3\\Private$\\pvtmsmq"; System.Messaging.MessageQueue msmq = new System.Messaging.MessageQueue(qname); msmq.Send("SampleMessage", System.Messaging.MessageQueueTransactionType.Single); msmq.Close(); } catch { throw; } }