10-13-2016, 05:38 AM
Try this code:
Code:
Dim oMQEnvironment
Dim oMQM
Dim oMQC
Dim oMQMessage
Dim oMQQueue
Dim intOpenOptions
'YOUR MQ DETAILS AND MESSAGE
'strMQMDLLPath = "C:\\Program Files (x86)\\IBM\WebSphere MQ\\bin\\amqmdnet.dll"
'strHostName= "Host Name"
'intPort = "Port Number"
'strChannel ="Channel Name"
'strMessage ="UFT Test Message"
'strMQManager = "Quemanager Name"
'strMessageQueue = "Queue Name"
' Create MQ Instances
Set oMQC = DotnetFactory.CreateInstance("IBM.WMQ.MQC",strMQMDLLPath)
'set the properties of the Queue manager
Set properties = DotNetFactory.CreateInstance("System.Collections.Hashtable")
properties.Add oMQC.HOST_NAME_PROPERTY, strHostName
properties.Add oMQC.PORT_PROPERTY, intPort
properties.Add oMQC.CHANNEL_PROPERTY, strChannel
'access the queue manager
Set oMQM = DotnetFactory.CreateInstance("IBM.WMQ.MQQueueManager",strMQMDLLPath,strMQManager,properties)
'Check if MQM Connected
If Err.Number <> 0 Then
Reporter.ReportEvent micFail , "Step: Creating MQM Object" , "Unable to Connect to MQ Manager at" & strHostName
'Exit Test
End If
Set oMQC = DotnetFactory.CreateInstance("IBM.WMQ.MQC",strMQMDLLPath)
Set oMQMessage = DotnetFactory.CreateInstance("IBM.WMQ.MQMessage",strMQMDLLPath)
'Declare Q open options
intOpenOptions = oMQC.MQOO_OUTPUT or oMQC.MQOO_FAIL_IF_QUIESCING ' 16 + 8192
'Open the Q to post the messages
If strRemoteMQManager = "" Then
Set oMQQueue = oMQM.AccessQueue(strMessageQueue , intOpenOptions)
Else
Set oMQQueue = oMQM.AccessQueue(strMessageQueue , intOpenOptions ,strRemoteMQManager, "","" )
End If
'Format Message
With oMQMessage
.CharacterSet = 819
.WriteString(strMessage)
End with
'Post Message
With oMQQueue
.Put(oMQMessage)
.Close()
End With