Refresh system variable using vbscript/QTP - vbscript

I want to set system variable MQSERVER for connecting to MQ using QTP. Each time this value is changed from QTP, I need to restart QTP to reflect changes.
E.g. in the system variables window,
MQSERVER = ABCD
change the variable using
Set objWSH = CreateObject("WScript.Shell")
Set objSystemVariables = objWSH.Environment("SYSTEM")
objSystemVariables(MQVariableName) = MQVariableValue
The variable is set correctly but does not reflect in QTP code when connecting to websphere MQ.
Immediately when I restart QTP, the QTP reads the env variable correctly. Can you please let me know how I can use the below API method. I am getting type mismatch in QTP.
lnRetVal = SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, "Environment", 2, 1000, Null) 'Getting type mismatch here
Updating my original question with the code that connects to queue manager.
The very basic thing that I am trying to do is (which can't be done without restarting QTP)
1) Connect to a queue manager
2) Put the message
3) Connect to another queue manager
4) Read the output
Const MQOO_OUTPUT = 16
Const MQOO_INPUT_AS_Q_DEF = 1
Set MQS = CreateObject("MQAX200.MQSession")
Set QM = MQS.AccessQueueManager(Environment.Value("MQName")) 'This will pass the queue name and access the queue manager.
Set MQQueue = QM.AccessQueue(strQueName, MQOO_INPUT_AS_Q_DEF Or MQOO_OUTPUT)
Set PutOptions = MQS.AccessPutMessageOptions()
PutOptions.Options = MQPMO_NO_SYNCPOINT
Set PutMsg = MQS.AccessMessage()
PutMsg.CharacterSet = 1208
PutMsg.MessageData = PutMsgStr 'the message text
PutMsg.ApplicationIdData = "INTF_0439B"
MQQueue.Put PutMsg, PutOptions 'write the message to queue.
Also, my websphere MQ version is 7.0.1.8

Related

why does LogonHostedExchangeMailbox get stuck with no error message?

We are using Redemption Library to access our e-mails. Scripts are automated on server and triggered by Task Scheduler at regular intervals. After server reboots we usually experience the problem with Session.Logon, since the user needs to log on again.
To avoid this problem, we are trying now to use LogonHostedExchangeMailbox Session method. Due to unknown reason the script gets stuck at this command. Could anyone advise what the reason might be? Here is the sample:
set Session = CreateObject("Redemption.RDOSession")
InboxName = "xxx#domain.com"
Session.LogonHostedExchangeMailbox InboxName,InboxName, "pwd" 'the script gets stuck here and does not throw any errors.
set oFolder = Session.GetFolderFromPath("\\"&InboxName&"\Inbox")
set items = oFolder.items
i = items.count
do until i = 0
if items.count > 0 then
set Mail = Items.Item(i)
wscript.echo Mail.Subject
'wscript.echo Mail.Body
end if
i = i - 1
loop
Session.Logoff
Thanks.

Not able to update the tester name in a Test Set from vbscript

I am been trying to search online for a solution but due to lack of knowledge in HP ALM I am not able to search proper hit tags
Set RunFactory = tsTest.RunFactory
Set obj_theRun = RunFactory.AddItem(CStr(testrunname))
obj_theRun.Status = sExecutionStatus '"Passed" '-- Status to be updated
obj_theRun.Tester = strTesterName
Getting error in this line object does not support obj_theRun.Tester
I just want to update the Tester column(Not Responsible tester) in Test set via vbscript. Please refer to the attached image at the very last column (TesterAny help is appreciated. Thank you in advance.
The documentation for ALM says the Tester Name can be specified by passing an array as the argument to AddItem.
https://admhelp.microfocus.com/alm/api_refs/ota/Content/ota/topic8805.html?Highlight=tester
An array consisting of the following elements:
Name - The name of the run (string. required).
Tester - The name of the user responsible (string. optional)
Location - The host name (string. optional). The default is the host name of the current machine
So change your code to this:
Set runFactory = tsTest.RunFactory
Dim newRunArgs(3)
newRunArgs(0) = testrunname ' `testrunname` is already a string so you don't need CStr.
newRunArgs(1) = "tester name goes here"
Set newRunArgs(2) = Nothing
Set newRun = RunFactory.AddItem( newRunArgs )
newRun.Status = sExecutionStatus '"Passed" '-- Status to be updated

XMS IBytesMessage causing problems with split ZIP file

Since upgrading MQ to "IBM MQ Explorer V9.1", the XMS libraries that always worked in previous versions have started behaving differently.
Essentially, the code still recognises the messages as IBytesMessage type, and successfully writes them to file via a Byte array, but the file itself, which is a split zip file, fails to reconstitute itself.
Here's the lions share of that code:
Dim FactoryFactory As XMSFactoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ)
'Create a ConnectionFactory Object
cfConnectionFactory = FactoryFactory.CreateConnectionFactory()
'this variable will contain the full path of any file downloaded from MQ
Dim strMQMessageOutputFileDestinationFilePath As String = ""
'This variable will be used to evaluate whether the MQ Message Output file exists
Dim fiMQMessageOutputFile As FileInfo = Nothing
'Set various Connection Factory properties
cfConnectionFactory.SetStringProperty(XMSC.WMQ_HOST_NAME, Me.HostName)
cfConnectionFactory.SetIntProperty(XMSC.WMQ_PORT, 1414)
cfConnectionFactory.SetStringProperty(XMSC.WMQ_CHANNEL, "SYSTEM.DEF.SVRCONN")
cfConnectionFactory.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, 1)
cfConnectionFactory.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, Me.QueueManager)
cfConnectionFactory.SetIntProperty(XMSC.WMQ_BROKER_VERSION, 0)
'Create a new Iconnection object via the Connection Factory
connection = cfConnectionFactory.CreateConnection()
'Create a sesion via the Connection Object, using ClientAcknowledge mode
'ClientAcknowledge is being used because it allows us to control precisely
'when a message should be removed from the queue
session = connection.CreateSession(False, AcknowledgeMode.ClientAcknowledge)
'Create a destination using the Session Object
destination = session.CreateQueue(Me.mstrDestinationURI)
destination.SetIntProperty(XMSC.DELIVERY_MODE, 1)
'Create a consumer using the Session & Destination Objects
Consumer = session.CreateConsumer(destination)
connection.Start()
'IMessage is the base class that is returned from the Consumer's Receive method
Dim recvMsg As IMessage = Nothing
' Retrieve message from Queue
recvMsg = Consumer.ReceiveNoWait
strFileNameFromMsg = If(Not recvMsg.PropertyExists("fileName"), "",
recvMsg.GetStringProperty("fileName"))
If TypeOf (recvMsg) Is IBytesMessage Then
'Binary Message
Dim msg As IBytesMessage = CType(recvMsg, IBytesMessage)
Dim buffer(msg.BodyLength) As Byte
msg.ReadBytes(buffer)
Dim content As String = Text.Encoding.UTF8.GetString(buffer)
'The PrepareDestinationFile Function will generate a unique file name for the new file
'and ensure that the file does not already exist on the drive
strMQMessageOutputFileDestinationFilePath = PrepareDestinationFile(strFileNameFromMsg)
'A FileStream object is needed to write a binary array to a file
Dim fsZipFile As FileStream = New FileStream(strMQMessageOutputFileDestinationFilePath, FileMode.Create)
'Write the contents of the Byte Array to the File via the FileStream object
fsZipFile.Write(buffer, 0, buffer.Length)
fsZipFile.Close()
End If
So, the code doesn't throw any kind of exception - the code still recognises the messages as IBytesMessage, but the files won't unzip correctly.
Oddly, If we use rfhutilc.exe, we can manually pull files provided we set the Write options as No Headers and not Include MQMD - but the code above always worked in the previous version of MQ / XMS
Any assistance you can provide would be very much appreciated.

Setting up mutt

I am a newbie to linux and need some help on using mutt for my office MS exchange server.
I have installed mutt 1.5.23 with configure options: --enable-imap --with-ssl and --enable-hcache.
I think, I am able to login to my exchange account, but can not go beyond (read or send mails). Mutt logs in and then says connection closed with message
--Mutt: (no mailbox) [Msgs:0] --- (date/date) ----------(all)
Is there a problem with my .muttrc or .msmtprc? I have no idea. I am pasting contents of both the files:
.muttrc:
source /usr/local/etc/Muttrc
set realname = "Ashish Goel"
set from = "ashish.goel#abc.com"
set envelope_from = yes
set imap_user = "ashish.goel#abc.com"
set folder = "imaps://owa.abc.com/owa/INBOX"
set imap_authenticators = "login"
set mbox = "imaps://owa.abc.com/owa/INBOX"
set spoolfile = "imaps://owa.abc.com/owa/INBOX"
set record = "imaps://owa.abc.com/owa/Sent Items"
set postponed = "imaps://owa.abc.com/owa/Drafts"
set copy=yes
set smtp_url = "smtps://ashish.goel#abc.com#owa.abc.com/owa"
mailboxes !
set header_cache = ~/.mutt/headers
set message_cachedir = ~/.mutt/cache/bodies
set certificate_file = /etc/ssl/certs
set imap_check_subscribed = yes
set imap_keepalive = 300
set imap_passive = no
set mail_check = 60
set timeout = 15
set sendmail = "/usr/bin/msmtp"
set ssl_verify_host = no
set ssl_verify_dates = no
.msmtprc:
account work
host owa.abc.com/owa
port 587
from ashish.goel#abc.com
user ashish.goel#abc.com
auth ntml
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log
ntlmdomain MYDOMAIN
protocol smtp
account default : work
I had this problem with an Exchange 2010 server both on this and later versions of mutt. In the end, I found the problem went away after I reset my subscribed folders in IMAP. I did this by using our web mail gateway which also uses IMAP. If you don't have such a facility, try the tips here to generate a list of subscribed folders, change it, and see if the updated list now works for you..
These are my functioning configuration files:
.muttrc:
set sendmail="/usr/bin/esmtp"
set envelope_from=yes
set realname="Kitone Elvis Peter"
set from="Kitone Elvis Peter <elviskitone#gmail.com>"
set use_from=yes
set edit_headers=yes
set smtp_url = "smtp://elviskitone#gmail.com#smtp.gmail.com:587/"
set smtp_pass =""
set imap_user = "elviskitone#gmail.com"
set imap_pass = ""
set mail_check = 30
set move = no
set imap_keepalive = 900
set header_cache = "~/.mutt/cache/headers"
set message_cachedir = "~/.mutt/cache/bodies"
set certificate_file = "~/.mutt/certificates"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
I used esmtprc instead of msmtprc.
.esmtprc:
identity "elviskitone#gmail.com"
hostname "smtp.gmail.com:587"
username "elviskitone#gmail.com"
password ""
starttls required
You also need to enable IMAP on your email if you haven't already. Plus, you need to give access to insecure or third party applications on your email, in email settings.

EWS. How to change DateTimeCreate property via EWS Proxy Classes

I write client application that uses Exchange Web Services Proxy Classes in order to connect to Exchange Web Services. Sometimes, I need create ItemType object and make it looks like as received letter. Therefore I need set up such properties of ItemType as DateTimeSent, DateTimeCreate, DateTimeReceived, but they haven’t public set assessTherefore I need set up such properties of ItemType as DateTimeSent, DateTimeCreate, DateTimeReceived, but they haven’t public set assessor.
I found resolve for some of them via MAPI properties:
ItemType newItem = xmlParser.LoadItem(); //info for newItem takes from xml
newItem.ExtendedProperty = new ExtendedPropertyType[1];
PathToExtendedFieldType q = new PathToExtendedFieldType();
q.PropertyTag = "3590"; //DeliveryTime
q.PropertyType = MapiPropertyTypeType.SystemTime;
newItem.ExtendedProperty[0] = new ExtendedPropertyType();
newItem.ExtendedProperty[0].ExtendedFieldURI = q;
newItem.ExtendedProperty[0].Item = new System.DateTime(2014, 5, 5, 5, 5, 5).ToString("yyyy-MM-ddTHH:mm:ssZ");
Well, it works for DateTimeSent and DateTimeReceived, but not for DateTimeCreate. ES dont give any errors, but DateTimeCreate doesnt change. I tried to UpdateItem with DateTimeCreate propery, but there was no result (update another properties runs fine).
P.S. MAPI ID for CreationTime: 0x3007.
Can someone help me with this problem?
I finally found a solution for this.
Source: https://social.msdn.microsoft.com/Forums/en-US/40a29c69-96d3-488b-8f0e-911dd5f04086/setting-a-emailmessage-datetimesent-and-isdraft?forum=exchangesvrdevelopment
You have to set 3 Extended MAPI properties PR_MESSAGE_FLAGS, PR_MESSAGE_DELIVERY_TIME, and PR_CLIENT_SUBMIT_TIME. Make sure when setting the Time you use UTC time.
For example:
EmailMessage emUploadEmail = new EmailMessage(service);
emUploadEmail.MimeContent = new MimeContent("us-ascii", bdBinaryData1);
// PR_CLIENT_SUBMIT_TIME
emUploadEmail.SetExtendedProperty(new ExtendedPropertyDefinition(57,MapiPropertyType.SystemTime), DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
// PR_MESSAGE_DELIVERY_TIME
emUploadEmail.SetExtendedProperty(new ExtendedPropertyDefinition(3590, MapiPropertyType.SystemTime), DateTime.Now.ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ"));
// PR_MESSAGE_FLAGS
emUploadEmail.SetExtendedProperty(new ExtendedPropertyDefinition(3591,MapiPropertyType.Integer),"1");
emUploadEmail.Save(WellKnownFolderName.Inbox);
Create and last modified dates are read-only and cannot be set. The store provider updates these properties internally.

Resources